aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/cli
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test/cask/cli')
-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
6 files changed, 71 insertions, 41 deletions
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.