95 lines
2.2 KiB
Ruby
Raw Normal View History

2017-03-05 19:26:56 +01:00
describe Hbc::Artifact::Binary, :cask do
2016-08-18 22:11:42 +03:00
let(:cask) {
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-binary.rb").tap do |cask|
2016-08-18 22:11:42 +03:00
shutup do
InstallHelper.install_without_artifacts(cask)
end
end
}
let(:expected_path) {
Hbc.binarydir.join("binary")
}
before(:each) do
Hbc.binarydir.mkpath
end
after(:each) do
FileUtils.rm expected_path if expected_path.exist?
end
it "links the binary to the proper directory" do
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to exist
2016-08-18 22:11:42 +03:00
end
it "avoids clobbering an existing binary by linking over it" do
FileUtils.touch expected_path
2016-11-29 11:04:45 +01:00
expect {
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
}.to raise_error(Hbc::CaskError)
2016-08-18 22:11:42 +03:00
2016-08-27 11:52:14 +02:00
expect(expected_path).not_to be :symlink?
2016-08-18 22:11:42 +03:00
end
it "clobbers an existing symlink" do
expected_path.make_symlink("/tmp")
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(File.readlink(expected_path)).not_to eq("/tmp")
end
it "respects --no-binaries flag" do
2017-03-06 20:37:13 +01:00
begin
Hbc::CLI.binaries = false
2016-08-18 22:11:42 +03:00
2017-03-06 20:37:13 +01:00
expect(Hbc::CLI).not_to be_binaries
2016-08-18 22:11:42 +03:00
2017-03-06 20:37:13 +01:00
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
2016-08-18 22:11:42 +03:00
2017-03-06 20:37:13 +01:00
expect(expected_path.exist?).to be false
ensure
Hbc::CLI.binaries = true
end
2016-08-18 22:11:42 +03:00
end
it "creates parent directory if it doesn't exist" do
FileUtils.rmdir Hbc.binarydir
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path.exist?).to be true
end
context "binary is inside an app package" do
let(:cask) {
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-embedded-binary.rb").tap do |cask|
2016-08-18 22:11:42 +03:00
shutup do
InstallHelper.install_without_artifacts(cask)
end
end
}
it "links the binary to the proper directory" do
shutup do
Hbc::Artifact::App.new(cask).install_phase
Hbc::Artifact::Binary.new(cask).install_phase
end
expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to exist
2016-08-18 22:11:42 +03:00
end
end
end