2017-03-05 19:26:56 +01:00
|
|
|
describe Hbc::Artifact::Artifact, :cask do
|
2016-12-06 16:36:34 +01:00
|
|
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") }
|
2016-10-19 16:42:31 -04:00
|
|
|
|
|
|
|
let(:install_phase) {
|
2016-10-23 14:30:32 +02:00
|
|
|
-> { Hbc::Artifact::Artifact.new(cask).install_phase }
|
2016-08-18 22:11:42 +03:00
|
|
|
}
|
|
|
|
|
2016-10-19 16:42:31 -04:00
|
|
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
|
|
|
let(:target_path) { Hbc.appdir.join("Caffeine.app") }
|
|
|
|
|
|
|
|
before do
|
2017-02-08 14:25:50 +01:00
|
|
|
InstallHelper.install_without_artifacts(cask)
|
2016-10-19 16:42:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "with no target" do
|
2016-12-06 16:36:34 +01:00
|
|
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact-no-target.rb") }
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-10-19 16:42:31 -04:00
|
|
|
it "fails to install with no target" do
|
2017-02-08 14:25:50 +01:00
|
|
|
expect(install_phase).to raise_error(Hbc::CaskInvalidError)
|
2016-10-19 16:42:31 -04:00
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "moves the artifact to the proper directory" do
|
|
|
|
shutup do
|
2016-10-19 16:42:31 -04:00
|
|
|
install_phase.call
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
2017-02-08 14:25:50 +01:00
|
|
|
expect(target_path).to be_a_directory
|
|
|
|
expect(source_path).not_to exist
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "avoids clobbering an existing artifact" do
|
2016-10-19 16:42:31 -04:00
|
|
|
target_path.mkpath
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2017-02-08 14:25:50 +01:00
|
|
|
expect {
|
2016-11-29 11:04:45 +01:00
|
|
|
shutup do
|
|
|
|
install_phase.call
|
|
|
|
end
|
2017-02-08 14:25:50 +01:00
|
|
|
}.to raise_error(Hbc::CaskError)
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2017-02-08 14:25:50 +01:00
|
|
|
expect(source_path).to be_a_directory
|
|
|
|
expect(target_path).to be_a_directory
|
|
|
|
expect(File.identical?(source_path, target_path)).to be false
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|