brew/Library/Homebrew/test/cask/depends_on_spec.rb

92 lines
2.9 KiB
Ruby
Raw Normal View History

2017-02-08 08:30:33 +01:00
# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb
2017-03-05 19:26:56 +01:00
describe "Satisfy Dependencies and Requirements", :cask do
2017-02-08 08:30:33 +01:00
subject {
lambda do
2017-07-29 19:55:05 +02:00
Hbc::Installer.new(cask).install
2017-02-08 08:30:33 +01:00
end
}
describe "depends_on cask" do
context "when depends_on cask is cyclic" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
2017-10-03 10:49:58 +02:00
it {
is_expected.to raise_error(Hbc::CaskCyclicDependencyError,
"Cask 'with-depends-on-cask-cyclic' includes cyclic dependencies on other Casks: with-depends-on-cask-cyclic-helper")
}
2017-02-08 08:30:33 +01:00
end
context do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-cask")) }
let(:dependency) { Hbc::CaskLoader.load(cask.depends_on.cask.first) }
2017-02-08 08:30:33 +01:00
it "installs the dependency of a Cask and the Cask itself" do
expect(subject).not_to raise_error
expect(cask).to be_installed
expect(dependency).to be_installed
end
end
end
describe "depends_on macos" do
context "given an array" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-array")) }
2017-02-08 08:30:33 +01:00
it { is_expected.not_to raise_error }
end
2017-09-10 16:30:30 +00:00
context "given a comparison" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-comparison")) }
2017-02-08 08:30:33 +01:00
it { is_expected.not_to raise_error }
end
context "given a string" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-string")) }
2017-02-08 08:30:33 +01:00
it { is_expected.not_to raise_error }
end
context "given a symbol" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-symbol")) }
2017-02-08 08:30:33 +01:00
it { is_expected.not_to raise_error }
end
context "when not satisfied" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-macos-failure")) }
2017-02-08 08:30:33 +01:00
it { is_expected.to raise_error(Hbc::CaskError) }
end
end
describe "depends_on arch" do
context "when satisfied" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-arch")) }
2017-02-08 08:30:33 +01:00
it { is_expected.not_to raise_error }
end
end
describe "depends_on x11" do
before(:each) do
allow(MacOS::X11).to receive(:installed?).and_return(x11_installed)
end
context "when satisfied" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-x11")) }
2017-02-08 08:30:33 +01:00
let(:x11_installed) { true }
it { is_expected.not_to raise_error }
end
context "when not satisfied" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-x11")) }
2017-02-08 08:30:33 +01:00
let(:x11_installed) { false }
it { is_expected.to raise_error(Hbc::CaskX11DependencyError) }
end
context "when depends_on x11: false" do
let(:cask) { Hbc::CaskLoader.load(cask_path("with-depends-on-x11-false")) }
2017-02-08 08:30:33 +01:00
let(:x11_installed) { false }
it { is_expected.not_to raise_error }
end
end
end