Skip to content

Commit

Permalink
chore: update tests for warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Mar 2, 2025
1 parent da47c82 commit 5a2bf48
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions spec/cli_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,62 @@
expect { do_press(options_manager) }.to output(/WARNING/).to_stdout
end
end
end

describe "#check_warnings" do
let(:options_manager) { Tebako::OptionsManager.new(options) }

context "when mode is runtime" do
before do
options["mode"] = "runtime"
end

it "does not display any warnings" do
expect { check_warnings(options_manager) }.not_to output.to_stdout
end
end

context "when package is within root" do
before do
options["mode"] = "both"
allow(options_manager).to receive(:package_within_root?).and_return(true)
allow(options_manager).to receive(:prefix_within_root?).and_return(false)
allow(self).to receive(:sleep)
end

it "displays package warning" do
expect { check_warnings(options_manager) }.to output(Tebako::CliHelpers::WARN).to_stdout
end
end

context "when prefix is within root" do
before do
options["mode"] = "both"
allow(options_manager).to receive(:package_within_root?).and_return(false)
allow(options_manager).to receive(:prefix_within_root?).and_return(true)
allow(self).to receive(:sleep)
end

it "displays prefix warning" do
expect { check_warnings(options_manager) }.to output(Tebako::CliHelpers::WARN2).to_stdout
end
end

context "when both package and prefix are within root" do
before do
options["mode"] = "both"
allow(options_manager).to receive(:package_within_root?).and_return(true)
allow(options_manager).to receive(:prefix_within_root?).and_return(true)
allow(self).to receive(:sleep)
end

it "displays both warnings" do
expect do
check_warnings(options_manager)
end.to output(Tebako::CliHelpers::WARN + Tebako::CliHelpers::WARN2).to_stdout
end
end
end

describe "#do_setup" do
let(:options_manager) { Tebako::OptionsManager.new(options) }
Expand Down

0 comments on commit 5a2bf48

Please sign in to comment.