aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMarkus Reiter2017-10-04 17:54:52 +0200
committerMarkus Reiter2017-10-04 18:52:34 +0200
commite9c587d7510ca6fe820bbc03db5bb6d0b9672c22 (patch)
treea7209c92bcc02b2d20a111f282f1bb0dbbd9c588 /Library/Homebrew/test
parent02362259a54c0b8d7399e7b19f0a56519cb1b9d1 (diff)
downloadbrew-e9c587d7510ca6fe820bbc03db5bb6d0b9672c22.tar.bz2
Refactor tests.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/cask/artifact/alt_target_spec.rb6
-rw-r--r--Library/Homebrew/test/cask/artifact/app_spec.rb2
-rw-r--r--Library/Homebrew/test/cask/artifact/binary_spec.rb36
-rw-r--r--Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb6
-rw-r--r--Library/Homebrew/test/cask/artifact/nested_container_spec.rb5
-rw-r--r--Library/Homebrew/test/cask/artifact/pkg_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/artifact/postflight_block_spec.rb10
-rw-r--r--Library/Homebrew/test/cask/artifact/preflight_block_spec.rb10
-rw-r--r--Library/Homebrew/test/cask/artifact/suite_spec.rb6
-rw-r--r--Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb6
-rw-r--r--Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb2
-rw-r--r--Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb2
-rw-r--r--Library/Homebrew/test/cask/cli/list_spec.rb5
-rw-r--r--Library/Homebrew/test/cask/dsl_spec.rb22
14 files changed, 76 insertions, 46 deletions
diff --git a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb
index fa5d7e650..f7543c05d 100644
--- a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb
@@ -3,7 +3,11 @@ describe Hbc::Artifact::App, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-alt-target.rb") }
let(:install_phase) {
- -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } }
+ lambda do
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
+ end
}
let(:source_path) { cask.staged_path.join("Caffeine.app") }
diff --git a/Library/Homebrew/test/cask/artifact/app_spec.rb b/Library/Homebrew/test/cask/artifact/app_spec.rb
index 5ecaaef22..e61fefaa0 100644
--- a/Library/Homebrew/test/cask/artifact/app_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/app_spec.rb
@@ -2,7 +2,7 @@ describe Hbc::Artifact::App, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-caffeine.rb") }
let(:command) { Hbc::SystemCommand }
let(:force) { false }
- let(:app) { cask.artifacts.select { |a| a.is_a?(described_class) }.first }
+ let(:app) { cask.artifacts.find { |a| a.is_a?(described_class) } }
let(:source_path) { cask.staged_path.join("Caffeine.app") }
let(:target_path) { Hbc.appdir.join("Caffeine.app") }
diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb
index 08b0af198..bf11ba237 100644
--- a/Library/Homebrew/test/cask/artifact/binary_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb
@@ -4,6 +4,7 @@ describe Hbc::Artifact::Binary, :cask do
InstallHelper.install_without_artifacts(cask)
end
}
+ let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
let(:expected_path) { Hbc.binarydir.join("binary") }
before(:each) do
@@ -26,8 +27,9 @@ describe Hbc::Artifact::Binary, :cask do
end
it "links the binary to the proper directory" do
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ artifacts.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to exist
@@ -46,8 +48,9 @@ describe Hbc::Artifact::Binary, :cask do
expect(FileUtils).to receive(:chmod)
.with("+x", cask.staged_path.join("naked_non_executable")).and_call_original
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ artifacts.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to be_executable
@@ -58,8 +61,9 @@ describe Hbc::Artifact::Binary, :cask do
FileUtils.touch expected_path
expect {
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ artifacts.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
}.to raise_error(Hbc::CaskError)
expect(expected_path).not_to be :symlink?
@@ -68,8 +72,9 @@ describe Hbc::Artifact::Binary, :cask do
it "clobbers an existing symlink" do
expected_path.make_symlink("/tmp")
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ artifacts.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(File.readlink(expected_path)).not_to eq("/tmp")
end
@@ -77,8 +82,9 @@ describe Hbc::Artifact::Binary, :cask do
it "creates parent directory if it doesn't exist" do
FileUtils.rmdir Hbc.binarydir
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ artifacts.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(expected_path.exist?).to be true
end
@@ -91,10 +97,12 @@ describe Hbc::Artifact::Binary, :cask do
}
it "links the binary to the proper directory" do
- cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
+ artifacts.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(expected_path).to be_a_symlink
expect(expected_path.readlink).to exist
diff --git a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
index 8dc30439d..1bf3bbbdb 100644
--- a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
@@ -2,7 +2,11 @@ describe Hbc::Artifact::Artifact, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-generic-artifact.rb") }
let(:install_phase) {
- -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } }
+ lambda do
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
+ end
}
let(:source_path) { cask.staged_path.join("Caffeine.app") }
diff --git a/Library/Homebrew/test/cask/artifact/nested_container_spec.rb b/Library/Homebrew/test/cask/artifact/nested_container_spec.rb
index 65759b5b7..d7bd6f59a 100644
--- a/Library/Homebrew/test/cask/artifact/nested_container_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/nested_container_spec.rb
@@ -5,8 +5,9 @@ describe Hbc::Artifact::NestedContainer, :cask do
InstallHelper.install_without_artifacts(c)
end
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(cask.staged_path.join("MyNestedApp.app")).to be_a_directory
end
diff --git a/Library/Homebrew/test/cask/artifact/pkg_spec.rb b/Library/Homebrew/test/cask/artifact/pkg_spec.rb
index d3028be9c..8ea5a1bb3 100644
--- a/Library/Homebrew/test/cask/artifact/pkg_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/pkg_spec.rb
@@ -8,7 +8,7 @@ describe Hbc::Artifact::Pkg, :cask do
describe "install_phase" do
it "runs the system installer on the specified pkgs" do
- pkg = cask.artifacts.select { |a| a.is_a?(described_class) }.first
+ pkg = cask.artifacts.find { |a| a.is_a?(described_class) }
expect(fake_system_command).to receive(:run!).with(
"/usr/sbin/installer",
@@ -25,7 +25,7 @@ describe Hbc::Artifact::Pkg, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") }
it "passes the choice changes xml to the system installer" do
- pkg = cask.artifacts.select { |a| a.is_a?(described_class) }.first
+ pkg = cask.artifacts.find { |a| a.is_a?(described_class) }
file = double(path: Pathname.new("/tmp/choices.xml"))
diff --git a/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb b/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb
index acd63671a..18cc4ca91 100644
--- a/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/postflight_block_spec.rb
@@ -11,8 +11,9 @@ describe Hbc::Artifact::PostflightBlock, :cask do
end
end
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(called).to be true
expect(yielded_arg).to be_kind_of(Hbc::DSL::Postflight)
@@ -31,8 +32,9 @@ describe Hbc::Artifact::PostflightBlock, :cask do
end
end
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.uninstall_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.uninstall_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(called).to be true
expect(yielded_arg).to be_kind_of(Hbc::DSL::UninstallPostflight)
diff --git a/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb b/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb
index 285a93ffb..405cdbd6f 100644
--- a/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/preflight_block_spec.rb
@@ -11,8 +11,9 @@ describe Hbc::Artifact::PreflightBlock, :cask do
end
end
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(called).to be true
expect(yielded_arg).to be_kind_of Hbc::DSL::Preflight
@@ -31,8 +32,9 @@ describe Hbc::Artifact::PreflightBlock, :cask do
end
end
- cask.artifacts.select { |a| a.is_a?(described_class) }
- .each { |artifact| artifact.uninstall_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.uninstall_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect(called).to be true
expect(yielded_arg).to be_kind_of Hbc::DSL::UninstallPreflight
diff --git a/Library/Homebrew/test/cask/artifact/suite_spec.rb b/Library/Homebrew/test/cask/artifact/suite_spec.rb
index 1826dffbb..01d25c4cc 100644
--- a/Library/Homebrew/test/cask/artifact/suite_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/suite_spec.rb
@@ -2,7 +2,11 @@ describe Hbc::Artifact::Suite, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-suite.rb") }
let(:install_phase) {
- -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } }
+ lambda do
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
+ end
}
let(:target_path) { Hbc.appdir.join("Caffeine") }
diff --git a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb
index ca8c44903..84072fd1a 100644
--- a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb
@@ -3,7 +3,11 @@ describe Hbc::Artifact::App, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-two-apps-correct.rb") }
let(:install_phase) {
- -> { cask.artifacts.select { |a| a.is_a?(described_class) }.each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } }
+ lambda do
+ cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
+ end
}
let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
diff --git a/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb
index da0bfbb78..a91e93405 100644
--- a/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/uninstall_no_zap_spec.rb
@@ -2,7 +2,7 @@ describe Hbc::Artifact::Zap, :cask do
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
let(:zap_artifact) {
- cask.artifacts.select { |a| a.is_a?(described_class) }.first
+ cask.artifacts.find { |a| a.is_a?(described_class) }
}
before(:each) do
diff --git a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb
index f1eb1b913..5e302d35a 100644
--- a/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb
+++ b/Library/Homebrew/test/cask/artifact/uninstall_zap_shared_examples.rb
@@ -1,6 +1,6 @@
shared_examples "#uninstall_phase or #zap_phase" do
let(:artifact_dsl_key) { described_class.dsl_key }
- let(:artifact) { cask.artifacts.select { |a| a.is_a?(described_class) }.first }
+ let(:artifact) { cask.artifacts.find { |a| a.is_a?(described_class) } }
let(:fake_system_command) { Hbc::FakeSystemCommand }
subject { artifact.public_send(:"#{artifact_dsl_key}_phase", command: fake_system_command) }
diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb
index 4f59aafe9..6a92289aa 100644
--- a/Library/Homebrew/test/cask/cli/list_spec.rb
+++ b/Library/Homebrew/test/cask/cli/list_spec.rb
@@ -72,8 +72,9 @@ describe Hbc::CLI::List, :cask do
it "lists the installed files for those Casks" do
casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))
- transmission.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }
- .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) }
+ transmission.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }.each do |artifact|
+ artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
+ end
expect {
described_class.run("local-transmission", "local-caffeine")
diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb
index 390e56b18..e4149398e 100644
--- a/Library/Homebrew/test/cask/dsl_spec.rb
+++ b/Library/Homebrew/test/cask/dsl_spec.rb
@@ -216,12 +216,12 @@ describe Hbc::DSL, :cask do
app "Bar.app"
end
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }.map(&:to_s)).to eq(["Foo.app (App)", "Bar.app (App)"])
+ expect(cask.artifacts.map(&:to_s)).to eq(["Foo.app (App)", "Bar.app (App)"])
end
it "allow app stanzas to be empty" do
cask = Hbc::Cask.new("cask-with-no-apps")
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::App) }).to be_empty
+ expect(cask.artifacts).to be_empty
end
end
@@ -249,7 +249,7 @@ describe Hbc::DSL, :cask do
pkg "Bar.pkg"
end
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Pkg) }.map(&:to_s)).to eq(["Foo.pkg (Pkg)", "Bar.pkg (Pkg)"])
+ expect(cask.artifacts.map(&:to_s)).to eq(["Foo.pkg (Pkg)", "Bar.pkg (Pkg)"])
end
end
@@ -501,10 +501,10 @@ describe Hbc::DSL, :cask do
let(:token) { "with-installer-script" }
it "allows installer script to be specified" do
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.first.path).to eq(Pathname("/usr/bin/true"))
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.first.args[:args]).to eq(["--flag"])
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.to_a[1].path).to eq(Pathname("/usr/bin/false"))
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.to_a[1].args[:args]).to eq(["--flag"])
+ expect(cask.artifacts.to_a[0].path).to eq(Pathname("/usr/bin/true"))
+ expect(cask.artifacts.to_a[0].args[:args]).to eq(["--flag"])
+ expect(cask.artifacts.to_a[1].path).to eq(Pathname("/usr/bin/false"))
+ expect(cask.artifacts.to_a[1].args[:args]).to eq(["--flag"])
end
end
@@ -512,7 +512,7 @@ describe Hbc::DSL, :cask do
let(:token) { "with-installer-manual" }
it "allows installer manual to be specified" do
- installer = cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Installer) }.first
+ installer = cask.artifacts.first
expect(installer).to be_a(Hbc::Artifact::Installer::ManualInstaller)
expect(installer.path).to eq(cask.staged_path.join("Caffeine.app"))
end
@@ -524,7 +524,7 @@ describe Hbc::DSL, :cask do
let(:token) { "stage-only" }
it "allows stage_only stanza to be specified" do
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::StageOnly) }).not_to be_empty
+ expect(cask.artifacts).to contain_exactly a_kind_of Hbc::Artifact::StageOnly
end
end
@@ -550,7 +550,7 @@ describe Hbc::DSL, :cask do
let(:token) { "appdir-interpolation" }
it "is allowed" do
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Binary) }.first.source).to eq(Hbc.appdir/"some/path")
+ expect(cask.artifacts.first.source).to eq(Hbc.appdir/"some/path")
end
end
@@ -563,7 +563,7 @@ describe Hbc::DSL, :cask do
binary "#{appdir}/some/path"
end
- expect(cask.artifacts.select { |a| a.is_a?(Hbc::Artifact::Binary) }.first.source).to eq(original_appdir/"some/path")
+ expect(cask.artifacts.first.source).to eq(original_appdir/"some/path")
ensure
Hbc.appdir = original_appdir
end