Skip to content
Snippets Groups Projects
Commit 0a6cecba authored by Markus Reiter's avatar Markus Reiter
Browse files

Fix tests.

parent e0b93f15
No related branches found
No related tags found
No related merge requests found
......@@ -26,9 +26,11 @@ describe Hbc::Artifact::Binary do
it "avoids clobbering an existing binary by linking over it" do
FileUtils.touch expected_path
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
expect {
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
}.to raise_error(Hbc::CaskError)
expect(expected_path).not_to be :symlink?
end
......
......@@ -69,9 +69,9 @@ describe Hbc::Artifact::App do
it "avoids clobbering an existing app by moving over it" do
target_path.mkpath
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path}'; not moving.
EOS
err = install_phase.must_raise(Hbc::CaskError)
err.message.must_equal("It seems there is already an App at '#{target_path}'.")
source_path.must_be :directory?
target_path.must_be :directory?
......
......@@ -71,9 +71,9 @@ describe Hbc::Artifact::App do
end
it "avoids clobbering an existing app" do
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path}'; not moving.
EOS
err = install_phase.must_raise(Hbc::CaskError)
err.message.must_equal("It seems there is already an App at '#{target_path}'.")
source_path.must_be :directory?
target_path.must_be :directory?
......@@ -92,12 +92,17 @@ describe Hbc::Artifact::App do
describe "target is both writable and user-owned" do
it "overwrites the existing app" do
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path}'; overwriting.
stdout = <<-EOS.undent
==> Removing App: '#{target_path}'
==> Moving App 'Caffeine.app' to '#{target_path}'
EOS
stderr = <<-EOS.undent
Warning: It seems there is already an App at '#{target_path}'; overwriting.
EOS
install_phase.must_output(stdout, stderr)
source_path.wont_be :exist?
target_path.must_be :directory?
......@@ -131,12 +136,17 @@ describe Hbc::Artifact::App do
command.expect_and_pass_through(chmod_cmd)
command.expect_and_pass_through(chmod_n_cmd)
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path}'; overwriting.
stdout = <<-EOS.undent
==> Removing App: '#{target_path}'
==> Moving App 'Caffeine.app' to '#{target_path}'
EOS
stderr = <<-EOS.undent
Warning: It seems there is already an App at '#{target_path}'; overwriting.
EOS
install_phase.must_output(stdout, stderr)
source_path.wont_be :exist?
target_path.must_be :directory?
......@@ -161,9 +171,9 @@ describe Hbc::Artifact::App do
end
it "leaves the target alone" do
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path}'; not moving.
EOS
err = install_phase.must_raise(Hbc::CaskError)
err.message.must_equal("It seems there is already an App at '#{target_path}'.")
File.symlink?(target_path).must_equal true
end
......@@ -172,12 +182,17 @@ describe Hbc::Artifact::App do
let(:force) { true }
it "overwrites the existing app" do
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path}'; overwriting.
stdout = <<-EOS.undent
==> Removing App: '#{target_path}'
==> Moving App 'Caffeine.app' to '#{target_path}'
EOS
stderr = <<-EOS.undent
Warning: It seems there is already an App at '#{target_path}'; overwriting.
EOS
install_phase.must_output(stdout, stderr)
source_path.wont_be :exist?
target_path.must_be :directory?
......
......@@ -34,8 +34,10 @@ describe Hbc::Artifact::Artifact do
it "avoids clobbering an existing artifact" do
target_path.mkpath
shutup do
install_phase.call
assert_raises Hbc::CaskError do
shutup do
install_phase.call
end
end
source_path.must_be :directory?
......
......@@ -33,8 +33,10 @@ describe Hbc::Artifact::Suite do
it "avoids clobbering an existing suite by moving over it" do
target_path.mkpath
shutup do
install_phase.call
assert_raises Hbc::CaskError do
shutup do
install_phase.call
end
end
source_path.must_be :directory?
......
......@@ -64,10 +64,13 @@ describe Hbc::Artifact::App do
it "when the first app of two already exists" do
target_path_mini.mkpath
install_phase.must_output <<-EOS.undent
==> It seems there is already an App at '#{target_path_mini}'; not moving.
==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}'
EOS
err = assert_raises Hbc::CaskError do
install_phase.must_output <<-EOS.undent
==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}'
EOS
end
err.message.must_equal("It seems there is already an App at '#{target_path_mini}'.")
source_path_mini.must_be :directory?
target_path_mini.must_be :directory?
......@@ -77,10 +80,13 @@ describe Hbc::Artifact::App do
it "when the second app of two already exists" do
target_path_pro.mkpath
install_phase.must_output <<-EOS.undent
==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}'
==> It seems there is already an App at '#{target_path_pro}'; not moving.
EOS
err = assert_raises Hbc::CaskError do
install_phase.must_output <<-EOS.undent
==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}'
EOS
end
err.message.must_equal("It seems there is already an App at '#{target_path_pro}'.")
source_path_pro.must_be :directory?
target_path_pro.must_be :directory?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment