aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask
diff options
context:
space:
mode:
authorMarkus Reiter2017-12-03 09:06:23 +0100
committerMarkus Reiter2018-01-27 21:47:18 +0100
commit6760d26319c6fcbf8ba74bd737530adc7831da22 (patch)
treeac7fefe897fa1bc4eb50f74959fb215f292bd441 /Library/Homebrew/test/cask
parentd558ec09332c74927dfb9182b19e11c5a73d8b52 (diff)
downloadbrew-6760d26319c6fcbf8ba74bd737530adc7831da22.tar.bz2
Create `Hbc::Config` class.
Diffstat (limited to 'Library/Homebrew/test/cask')
-rw-r--r--Library/Homebrew/test/cask/artifact/alt_target_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/artifact/app_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/artifact/binary_spec.rb6
-rw-r--r--Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb2
-rw-r--r--Library/Homebrew/test/cask/artifact/suite_spec.rb2
-rw-r--r--Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb6
-rw-r--r--Library/Homebrew/test/cask/cli/install_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/cli/list_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/cli/options_spec.rb60
-rw-r--r--Library/Homebrew/test/cask/cli/uninstall_spec.rb12
-rw-r--r--Library/Homebrew/test/cask/cli/upgrade_spec.rb28
-rw-r--r--Library/Homebrew/test/cask/cli/zap_spec.rb4
-rw-r--r--Library/Homebrew/test/cask/cli_spec.rb7
-rw-r--r--Library/Homebrew/test/cask/dsl_spec.rb8
-rw-r--r--Library/Homebrew/test/cask/installer_spec.rb14
15 files changed, 99 insertions, 66 deletions
diff --git a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb
index 847bf25fa..2168ac606 100644
--- a/Library/Homebrew/test/cask/artifact/alt_target_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/alt_target_spec.rb
@@ -11,7 +11,7 @@ describe Hbc::Artifact::App, :cask do
}
let(:source_path) { cask.staged_path.join("Caffeine.app") }
- let(:target_path) { Hbc.appdir.join("AnotherName.app") }
+ let(:target_path) { Hbc::Config.global.appdir.join("AnotherName.app") }
before do
InstallHelper.install_without_artifacts(cask)
@@ -58,7 +58,7 @@ describe Hbc::Artifact::App, :cask do
expect(target_path).to be_a_directory
expect(source_path).not_to exist
- expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist
+ expect(Hbc::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
end
diff --git a/Library/Homebrew/test/cask/artifact/app_spec.rb b/Library/Homebrew/test/cask/artifact/app_spec.rb
index 285cc4f31..97e19165b 100644
--- a/Library/Homebrew/test/cask/artifact/app_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/app_spec.rb
@@ -5,7 +5,7 @@ describe Hbc::Artifact::App, :cask do
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") }
+ let(:target_path) { Hbc::Config.global.appdir.join("Caffeine.app") }
let(:install_phase) { app.install_phase(command: command, force: force) }
let(:uninstall_phase) { app.uninstall_phase(command: command, force: force) }
@@ -53,7 +53,7 @@ describe Hbc::Artifact::App, :cask do
expect(target_path).to be_a_directory
expect(source_path).not_to exist
- expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist
+ expect(Hbc::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
end
diff --git a/Library/Homebrew/test/cask/artifact/binary_spec.rb b/Library/Homebrew/test/cask/artifact/binary_spec.rb
index e9514d9ae..d072060cc 100644
--- a/Library/Homebrew/test/cask/artifact/binary_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/binary_spec.rb
@@ -5,7 +5,7 @@ describe Hbc::Artifact::Binary, :cask do
end
}
let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
- let(:expected_path) { Hbc.binarydir.join("binary") }
+ let(:expected_path) { Hbc::Config.global.binarydir.join("binary") }
after(:each) do
FileUtils.rm expected_path if expected_path.exist?
@@ -38,7 +38,7 @@ describe Hbc::Artifact::Binary, :cask do
end
}
- let(:expected_path) { Hbc.binarydir.join("naked_non_executable") }
+ let(:expected_path) { Hbc::Config.global.binarydir.join("naked_non_executable") }
it "makes the binary executable" do
expect(FileUtils).to receive(:chmod)
@@ -76,7 +76,7 @@ describe Hbc::Artifact::Binary, :cask do
end
it "creates parent directory if it doesn't exist" do
- FileUtils.rmdir Hbc.binarydir
+ FileUtils.rmdir Hbc::Config.global.binarydir
artifacts.each do |artifact|
artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false)
diff --git a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
index ea567abee..7e1285476 100644
--- a/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
@@ -10,7 +10,7 @@ describe Hbc::Artifact::Artifact, :cask do
}
let(:source_path) { cask.staged_path.join("Caffeine.app") }
- let(:target_path) { Hbc.appdir.join("Caffeine.app") }
+ let(:target_path) { Hbc::Config.global.appdir.join("Caffeine.app") }
before do
InstallHelper.install_without_artifacts(cask)
diff --git a/Library/Homebrew/test/cask/artifact/suite_spec.rb b/Library/Homebrew/test/cask/artifact/suite_spec.rb
index 80d3e917f..62a2fbfd7 100644
--- a/Library/Homebrew/test/cask/artifact/suite_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/suite_spec.rb
@@ -9,7 +9,7 @@ describe Hbc::Artifact::Suite, :cask do
end
}
- let(:target_path) { Hbc.appdir.join("Caffeine") }
+ let(:target_path) { Hbc::Config.global.appdir.join("Caffeine") }
let(:source_path) { cask.staged_path.join("Caffeine") }
before(:each) do
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 8367dc27d..0d6f47d13 100644
--- a/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb
+++ b/Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb
@@ -11,10 +11,10 @@ describe Hbc::Artifact::App, :cask do
}
let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
- let(:target_path_mini) { Hbc.appdir.join("Caffeine Mini.app") }
+ let(:target_path_mini) { Hbc::Config.global.appdir.join("Caffeine Mini.app") }
let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
- let(:target_path_pro) { Hbc.appdir.join("Caffeine Pro.app") }
+ let(:target_path_pro) { Hbc::Config.global.appdir.join("Caffeine Pro.app") }
before(:each) do
InstallHelper.install_without_artifacts(cask)
@@ -52,7 +52,7 @@ describe Hbc::Artifact::App, :cask do
expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
- expect(Hbc.appdir.join("Caffeine Deluxe.app")).not_to exist
+ expect(Hbc::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
end
diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb
index 25d6cdc93..cc5450c79 100644
--- a/Library/Homebrew/test/cask/cli/install_spec.rb
+++ b/Library/Homebrew/test/cask/cli/install_spec.rb
@@ -23,9 +23,9 @@ describe Hbc::CLI::Install, :cask do
described_class.run("local-transmission", "local-caffeine")
expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed
- expect(Hbc.appdir.join("Transmission.app")).to be_a_directory
+ expect(Hbc::Config.global.appdir.join("Transmission.app")).to be_a_directory
expect(Hbc::CaskLoader.load(cask_path("local-caffeine"))).to be_installed
- expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory
+ expect(Hbc::Config.global.appdir.join("Caffeine.app")).to be_a_directory
end
it "skips double install (without nuking existing installation)" do
diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb
index eef233acc..98eb6a8da 100644
--- a/Library/Homebrew/test/cask/cli/list_spec.rb
+++ b/Library/Homebrew/test/cask/cli/list_spec.rb
@@ -80,9 +80,9 @@ describe Hbc::CLI::List, :cask do
described_class.run("local-transmission", "local-caffeine")
}.to output(<<~EOS).to_stdout
==> Apps
- #{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv})
+ #{Hbc::Config.global.appdir.join("Transmission.app")} (#{Hbc::Config.global.appdir.join("Transmission.app").abv})
==> Apps
- Missing App: #{Hbc.appdir.join("Caffeine.app")}
+ Missing App: #{Hbc::Config.global.appdir.join("Caffeine.app")}
EOS
end
end
diff --git a/Library/Homebrew/test/cask/cli/options_spec.rb b/Library/Homebrew/test/cask/cli/options_spec.rb
index 82d830795..8b084113c 100644
--- a/Library/Homebrew/test/cask/cli/options_spec.rb
+++ b/Library/Homebrew/test/cask/cli/options_spec.rb
@@ -1,106 +1,136 @@
describe Hbc::CLI, :cask do
it "supports setting the appdir" do
+ allow(Hbc::Config.global).to receive(:appdir).and_call_original
+
described_class.new.process_options("help", "--appdir=/some/path/foo")
- expect(Hbc.appdir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.appdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the appdir from ENV" do
+ allow(Hbc::Config.global).to receive(:appdir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.appdir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.appdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the prefpanedir" do
+ allow(Hbc::Config.global).to receive(:prefpanedir).and_call_original
+
described_class.new.process_options("help", "--prefpanedir=/some/path/foo")
- expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.prefpanedir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the prefpanedir from ENV" do
+ allow(Hbc::Config.global).to receive(:prefpanedir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.prefpanedir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the qlplugindir" do
+ allow(Hbc::Config.global).to receive(:qlplugindir).and_call_original
+
described_class.new.process_options("help", "--qlplugindir=/some/path/foo")
- expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.qlplugindir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the qlplugindir from ENV" do
+ allow(Hbc::Config.global).to receive(:qlplugindir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.qlplugindir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the colorpickerdir" do
+ allow(Hbc::Config.global).to receive(:colorpickerdir).and_call_original
+
described_class.new.process_options("help", "--colorpickerdir=/some/path/foo")
- expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the colorpickerdir from ENV" do
+ allow(Hbc::Config.global).to receive(:colorpickerdir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.colorpickerdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the dictionarydir" do
+ allow(Hbc::Config.global).to receive(:dictionarydir).and_call_original
+
described_class.new.process_options("help", "--dictionarydir=/some/path/foo")
- expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.dictionarydir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the dictionarydir from ENV" do
+ allow(Hbc::Config.global).to receive(:dictionarydir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.dictionarydir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the fontdir" do
+ allow(Hbc::Config.global).to receive(:fontdir).and_call_original
+
described_class.new.process_options("help", "--fontdir=/some/path/foo")
- expect(Hbc.fontdir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.fontdir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the fontdir from ENV" do
+ allow(Hbc::Config.global).to receive(:fontdir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.fontdir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.fontdir).to eq(Pathname.new("/some/path/bar"))
end
it "supports setting the servicedir" do
+ allow(Hbc::Config.global).to receive(:servicedir).and_call_original
+
described_class.new.process_options("help", "--servicedir=/some/path/foo")
- expect(Hbc.servicedir).to eq(Pathname.new("/some/path/foo"))
+ expect(Hbc::Config.global.servicedir).to eq(Pathname.new("/some/path/foo"))
end
it "supports setting the servicedir from ENV" do
+ allow(Hbc::Config.global).to receive(:servicedir).and_call_original
+
ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar"
described_class.new.process_options("help")
- expect(Hbc.servicedir).to eq(Pathname.new("/some/path/bar"))
+ expect(Hbc::Config.global.servicedir).to eq(Pathname.new("/some/path/bar"))
end
it "allows additional options to be passed through" do
+ allow(Hbc::Config.global).to receive(:appdir).and_call_original
+
rest = described_class.new.process_options("edit", "foo", "--create", "--appdir=/some/path/qux")
- expect(Hbc.appdir).to eq(Pathname.new("/some/path/qux"))
+ expect(Hbc::Config.global.appdir).to eq(Pathname.new("/some/path/qux"))
expect(rest).to eq(%w[edit foo --create])
end
diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb
index 345e1b9f2..322394de4 100644
--- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb
+++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb
@@ -50,9 +50,9 @@ describe Hbc::CLI::Uninstall, :cask do
described_class.run("local-caffeine", "local-transmission")
expect(caffeine).not_to be_installed
- expect(Hbc.appdir.join("Transmission.app")).not_to exist
+ expect(Hbc::Config.global.appdir.join("Transmission.app")).not_to exist
expect(transmission).not_to be_installed
- expect(Hbc.appdir.join("Caffeine.app")).not_to exist
+ expect(Hbc::Config.global.appdir.join("Caffeine.app")).not_to exist
end
it "calls `uninstall` before removing artifacts" do
@@ -61,14 +61,14 @@ describe Hbc::CLI::Uninstall, :cask do
Hbc::Installer.new(cask).install
expect(cask).to be_installed
- expect(Hbc.appdir.join("MyFancyApp.app")).to exist
+ expect(Hbc::Config.global.appdir.join("MyFancyApp.app")).to exist
expect {
described_class.run("with-uninstall-script-app")
}.not_to raise_error
expect(cask).not_to be_installed
- expect(Hbc.appdir.join("MyFancyApp.app")).not_to exist
+ expect(Hbc::Config.global.appdir.join("MyFancyApp.app")).not_to exist
end
it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do
@@ -78,7 +78,7 @@ describe Hbc::CLI::Uninstall, :cask do
expect(cask).to be_installed
- Hbc.appdir.join("MyFancyApp.app").rmtree
+ Hbc::Config.global.appdir.join("MyFancyApp.app").rmtree
expect { described_class.run("with-uninstall-script-app") }
.to raise_error(Hbc::CaskError, /uninstall script .* does not exist/)
@@ -141,7 +141,7 @@ describe Hbc::CLI::Uninstall, :cask do
end
describe "when Casks in Taps have been renamed or removed" do
- let(:app) { Hbc.appdir.join("ive-been-renamed.app") }
+ let(:app) { Hbc::Config.global.appdir.join("ive-been-renamed.app") }
let(:caskroom_path) { Hbc.caskroom.join("ive-been-renamed").tap(&:mkpath) }
let(:saved_caskfile) { caskroom_path.join(".metadata", "latest", "timestamp", "Casks").join("ive-been-renamed.rb") }
diff --git a/Library/Homebrew/test/cask/cli/upgrade_spec.rb b/Library/Homebrew/test/cask/cli/upgrade_spec.rb
index 49775156e..af026157e 100644
--- a/Library/Homebrew/test/cask/cli/upgrade_spec.rb
+++ b/Library/Homebrew/test/cask/cli/upgrade_spec.rb
@@ -22,9 +22,9 @@ describe Hbc::CLI::Upgrade, :cask do
describe 'without --greedy it ignores the Casks with "version latest" or "auto_updates true"' do
it "updates all the installed Casks when no token is provided" do
local_caffeine = Hbc::CaskLoader.load("local-caffeine")
- local_caffeine_path = Hbc.appdir.join("Caffeine.app")
+ local_caffeine_path = Hbc::Config.global.appdir.join("Caffeine.app")
local_transmission = Hbc::CaskLoader.load("local-transmission")
- local_transmission_path = Hbc.appdir.join("Transmission.app")
+ local_transmission_path = Hbc::Config.global.appdir.join("Transmission.app")
expect(local_caffeine).to be_installed
expect(local_caffeine_path).to be_a_directory
@@ -47,9 +47,9 @@ describe Hbc::CLI::Upgrade, :cask do
it "updates only the Casks specified in the command line" do
local_caffeine = Hbc::CaskLoader.load("local-caffeine")
- local_caffeine_path = Hbc.appdir.join("Caffeine.app")
+ local_caffeine_path = Hbc::Config.global.appdir.join("Caffeine.app")
local_transmission = Hbc::CaskLoader.load("local-transmission")
- local_transmission_path = Hbc.appdir.join("Transmission.app")
+ local_transmission_path = Hbc::Config.global.appdir.join("Transmission.app")
expect(local_caffeine).to be_installed
expect(local_caffeine_path).to be_a_directory
@@ -72,9 +72,9 @@ describe Hbc::CLI::Upgrade, :cask do
it 'updates "auto_updates" and "latest" Casks when their tokens are provided in the command line' do
local_caffeine = Hbc::CaskLoader.load("local-caffeine")
- local_caffeine_path = Hbc.appdir.join("Caffeine.app")
+ local_caffeine_path = Hbc::Config.global.appdir.join("Caffeine.app")
auto_updates = Hbc::CaskLoader.load("auto-updates")
- auto_updates_path = Hbc.appdir.join("MyFancyApp.app")
+ auto_updates_path = Hbc::Config.global.appdir.join("MyFancyApp.app")
expect(local_caffeine).to be_installed
expect(local_caffeine_path).to be_a_directory
@@ -99,14 +99,14 @@ describe Hbc::CLI::Upgrade, :cask do
describe "with --greedy it checks additional Casks" do
it 'includes the Casks with "auto_updates true" or "version latest"' do
local_caffeine = Hbc::CaskLoader.load("local-caffeine")
- local_caffeine_path = Hbc.appdir.join("Caffeine.app")
+ local_caffeine_path = Hbc::Config.global.appdir.join("Caffeine.app")
auto_updates = Hbc::CaskLoader.load("auto-updates")
- auto_updates_path = Hbc.appdir.join("MyFancyApp.app")
+ auto_updates_path = Hbc::Config.global.appdir.join("MyFancyApp.app")
local_transmission = Hbc::CaskLoader.load("local-transmission")
- local_transmission_path = Hbc.appdir.join("Transmission.app")
+ local_transmission_path = Hbc::Config.global.appdir.join("Transmission.app")
version_latest = Hbc::CaskLoader.load("version-latest")
- version_latest_path_1 = Hbc.appdir.join("Caffeine Mini.app")
- version_latest_path_2 = Hbc.appdir.join("Caffeine Pro.app")
+ version_latest_path_1 = Hbc::Config.global.appdir.join("Caffeine Mini.app")
+ version_latest_path_2 = Hbc::Config.global.appdir.join("Caffeine Pro.app")
expect(local_caffeine).to be_installed
expect(local_caffeine_path).to be_a_directory
@@ -147,7 +147,7 @@ describe Hbc::CLI::Upgrade, :cask do
it 'does not include the Casks with "auto_updates true" when the version did not change' do
cask = Hbc::CaskLoader.load("auto-updates")
- cask_path = Hbc.appdir.join("MyFancyApp.app")
+ cask_path = Hbc::Config.global.appdir.join("MyFancyApp.app")
expect(cask).to be_installed
expect(cask_path).to be_a_directory
@@ -188,7 +188,7 @@ describe Hbc::CLI::Upgrade, :cask do
it "restores the old Cask if the upgrade failed" do
will_fail_if_upgraded = Hbc::CaskLoader.load("will-fail-if-upgraded")
- will_fail_if_upgraded_path = Hbc.appdir.join("container")
+ will_fail_if_upgraded_path = Hbc::Config.global.appdir.join("container")
expect(will_fail_if_upgraded).to be_installed
expect(will_fail_if_upgraded_path).to be_a_file
@@ -206,7 +206,7 @@ describe Hbc::CLI::Upgrade, :cask do
it "does not restore the old Cask if the upgrade failed pre-install" do
bad_checksum = Hbc::CaskLoader.load("bad-checksum")
- bad_checksum_path = Hbc.appdir.join("Caffeine.app")
+ bad_checksum_path = Hbc::Config.global.appdir.join("Caffeine.app")
expect(bad_checksum).to be_installed
expect(bad_checksum_path).to be_a_directory
diff --git a/Library/Homebrew/test/cask/cli/zap_spec.rb b/Library/Homebrew/test/cask/cli/zap_spec.rb
index 05c882854..e85120f5f 100644
--- a/Library/Homebrew/test/cask/cli/zap_spec.rb
+++ b/Library/Homebrew/test/cask/cli/zap_spec.rb
@@ -23,9 +23,9 @@ describe Hbc::CLI::Zap, :cask do
described_class.run("local-caffeine", "local-transmission")
expect(caffeine).not_to be_installed
- expect(Hbc.appdir.join("Caffeine.app")).not_to be_a_symlink
+ expect(Hbc::Config.global.appdir.join("Caffeine.app")).not_to be_a_symlink
expect(transmission).not_to be_installed
- expect(Hbc.appdir.join("Transmission.app")).not_to be_a_symlink
+ expect(Hbc::Config.global.appdir.join("Transmission.app")).not_to be_a_symlink
end
# TODO: Explicit test that both zap and uninstall directives get dispatched.
diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb
index f88af4188..e88b24ba2 100644
--- a/Library/Homebrew/test/cask/cli_spec.rb
+++ b/Library/Homebrew/test/cask/cli_spec.rb
@@ -57,10 +57,13 @@ describe Hbc::CLI, :cask do
end
it "respects the env variable when choosing what appdir to create" do
- allow(ENV).to receive(:[])
+ allow(ENV).to receive(:[]).and_call_original
allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir")
- expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir"))
+ allow(Hbc::Config.global).to receive(:appdir).and_call_original
+
described_class.run("noop")
+
+ expect(Hbc::Config.global.appdir).to eq(Pathname.new("/custom/appdir"))
end
it "exits with a status of 1 when something goes wrong" do
diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb
index cd296b5ab..d3bb46264 100644
--- a/Library/Homebrew/test/cask/dsl_spec.rb
+++ b/Library/Homebrew/test/cask/dsl_spec.rb
@@ -551,14 +551,14 @@ describe Hbc::DSL, :cask do
let(:token) { "appdir-interpolation" }
it "is allowed" do
- expect(cask.artifacts.first.source).to eq(Hbc.appdir/"some/path")
+ expect(cask.artifacts.first.source).to eq(Hbc::Config.global.appdir/"some/path")
end
end
it "does not include a trailing slash" do
begin
- original_appdir = Hbc.appdir
- Hbc.appdir = "#{original_appdir}/"
+ original_appdir = Hbc::Config.global.appdir
+ Hbc::Config.global.appdir = "#{original_appdir}/"
cask = Hbc::Cask.new("appdir-trailing-slash") do
binary "#{appdir}/some/path"
@@ -566,7 +566,7 @@ describe Hbc::DSL, :cask do
expect(cask.artifacts.first.source).to eq(original_appdir/"some/path")
ensure
- Hbc.appdir = original_appdir
+ Hbc::Config.global.appdir = original_appdir
end
end
end
diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb
index 2dc27f04c..5fc730b33 100644
--- a/Library/Homebrew/test/cask/installer_spec.rb
+++ b/Library/Homebrew/test/cask/installer_spec.rb
@@ -10,7 +10,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(caffeine).install
expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).to be_a_directory
- expect(Hbc.appdir.join("Caffeine.app")).to be_a_directory
+ expect(Hbc::Config.global.appdir.join("Caffeine.app")).to be_a_directory
end
it "works with dmg-based Casks" do
@@ -19,7 +19,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(asset).install
expect(Hbc.caskroom.join("container-dmg", asset.version)).to be_a_directory
- expect(Hbc.appdir.join("container")).to be_a_file
+ expect(Hbc::Config.global.appdir.join("container")).to be_a_file
end
it "works with tar-gz-based Casks" do
@@ -28,7 +28,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(asset).install
expect(Hbc.caskroom.join("container-tar-gz", asset.version)).to be_a_directory
- expect(Hbc.appdir.join("container")).to be_a_file
+ expect(Hbc::Config.global.appdir.join("container")).to be_a_file
end
it "works with xar-based Casks" do
@@ -37,7 +37,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(asset).install
expect(Hbc.caskroom.join("container-xar", asset.version)).to be_a_directory
- expect(Hbc.appdir.join("container")).to be_a_file
+ expect(Hbc::Config.global.appdir.join("container")).to be_a_file
end
it "works with pure bzip2-based Casks" do
@@ -46,7 +46,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(asset).install
expect(Hbc.caskroom.join("container-bzip2", asset.version)).to be_a_directory
- expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).to be_a_file
+ expect(Hbc::Config.global.appdir.join("container-bzip2--#{asset.version}")).to be_a_file
end
it "works with pure gzip-based Casks" do
@@ -55,7 +55,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(asset).install
expect(Hbc.caskroom.join("container-gzip", asset.version)).to be_a_directory
- expect(Hbc.appdir.join("container")).to be_a_file
+ expect(Hbc::Config.global.appdir.join("container")).to be_a_file
end
it "blows up on a bad checksum" do
@@ -183,7 +183,7 @@ describe Hbc::Installer, :cask do
Hbc::Installer.new(nested_app).install
- expect(Hbc.appdir.join("MyNestedApp.app")).to be_a_directory
+ expect(Hbc::Config.global.appdir.join("MyNestedApp.app")).to be_a_directory
end
it "generates and finds a timestamped metadata directory for an installed Cask" do