diff options
| author | Markus Reiter | 2017-06-14 12:18:38 +0200 |
|---|---|---|
| committer | GitHub | 2017-06-14 12:18:38 +0200 |
| commit | bfcb3928f86ea7e4b9274d9f85a502a3b38ac2d4 (patch) | |
| tree | 413c4d77a58c9cab4e57e5155bb5022d5d248e4d /Library/Homebrew/test | |
| parent | 054ed10cb1ea2d64c39ba2a3208c14a33d31274d (diff) | |
| parent | 9c8f7138f35625878e017559c896441fda6f357c (diff) | |
| download | brew-bfcb3928f86ea7e4b9274d9f85a502a3b38ac2d4.tar.bz2 | |
Merge pull request #2771 from reitermarkus/cask-exceptions
🔨 Refactor Cask exceptions.
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/cask/cli/audit_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/cat_spec.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/fetch_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/install_spec.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/style_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/uninstall_spec.rb | 20 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/zap_spec.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/dsl_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/installer_spec.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/verify/checksum_spec.rb | 2 |
10 files changed, 24 insertions, 42 deletions
diff --git a/Library/Homebrew/test/cask/cli/audit_spec.rb b/Library/Homebrew/test/cask/cli/audit_spec.rb index 412db1481..01f506c8c 100644 --- a/Library/Homebrew/test/cask/cli/audit_spec.rb +++ b/Library/Homebrew/test/cask/cli/audit_spec.rb @@ -1,5 +1,5 @@ describe Hbc::CLI::Audit, :cask do - let(:cask) { double } + let(:cask) { double("cask", token: nil) } describe "selection of Casks to audit" do it "audits all Casks if no tokens are given" do diff --git a/Library/Homebrew/test/cask/cli/cat_spec.rb b/Library/Homebrew/test/cask/cli/cat_spec.rb index 28089b2f1..b726a0b36 100644 --- a/Library/Homebrew/test/cask/cli/cat_spec.rb +++ b/Library/Homebrew/test/cask/cli/cat_spec.rb @@ -34,9 +34,9 @@ describe Hbc::CLI::Cat, :cask do end it "raises an exception when the Cask does not exist" do - expect { - Hbc::CLI::Cat.run("notacask") - }.to raise_error(Hbc::CaskUnavailableError) + expect { Hbc::CLI::Cat.run("notacask") } + .to output(/is unavailable/).to_stderr + .and raise_error(Hbc::CaskError, "Cat incomplete.") end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/fetch_spec.rb b/Library/Homebrew/test/cask/cli/fetch_spec.rb index 9f3056631..54bdfc0c8 100644 --- a/Library/Homebrew/test/cask/cli/fetch_spec.rb +++ b/Library/Homebrew/test/cask/cli/fetch_spec.rb @@ -54,7 +54,7 @@ describe Hbc::CLI::Fetch, :cask do shutup do Hbc::CLI::Fetch.run("notacask") end - }.to raise_error(Hbc::CaskUnavailableError) + }.to raise_error(Hbc::CaskError, "Fetch incomplete.") end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb index b1b26c867..cf69b5d86 100644 --- a/Library/Homebrew/test/cask/cli/install_spec.rb +++ b/Library/Homebrew/test/cask/cli/install_spec.rb @@ -41,7 +41,7 @@ describe Hbc::CLI::Install, :cask do expect { Hbc::CLI::Install.run("local-transmission") - }.to output(/Warning: A Cask for local-transmission is already installed./).to_stderr + }.to output(/Warning: Cask 'local-transmission' is already installed./).to_stderr end it "allows double install with --force" do @@ -70,7 +70,7 @@ describe Hbc::CLI::Install, :cask do shutup do Hbc::CLI::Install.run("notacask") end - }.to raise_error(Hbc::CaskError) + }.to raise_error(Hbc::CaskError, "Install incomplete.") end it "returns a suggestion for a misspelled Cask" do @@ -80,7 +80,7 @@ describe Hbc::CLI::Install, :cask do rescue Hbc::CaskError nil end - }.to output(/No available Cask for localcaffeine\. Did you mean:\nlocal-caffeine/).to_stderr + }.to output(/Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean:\nlocal-caffeine/).to_stderr end it "returns multiple suggestions for a Cask fragment" do @@ -90,7 +90,7 @@ describe Hbc::CLI::Install, :cask do rescue Hbc::CaskError nil end - }.to output(/No available Cask for local-caf\. Did you mean one of:\nlocal-caffeine/).to_stderr + }.to output(/Cask 'local-caf' is unavailable: No Cask with this name exists\. Did you mean one of:\nlocal-caffeine/).to_stderr end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/style_spec.rb b/Library/Homebrew/test/cask/cli/style_spec.rb index a5dcf6f6f..640eca5f4 100644 --- a/Library/Homebrew/test/cask/cli/style_spec.rb +++ b/Library/Homebrew/test/cask/cli/style_spec.rb @@ -107,7 +107,7 @@ describe Hbc::CLI::Style, :cask do end it "tries to find paths for all tokens" do - expect(Hbc::CaskLoader).to receive(:path).twice + expect(Hbc::CaskLoader).to receive(:load).twice.and_return(double("cask", sourcefile_path: nil)) subject end end diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index bc1f52613..cc640fad7 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -17,15 +17,15 @@ describe Hbc::CLI::Uninstall, :cask do end it "shows an error when a bad Cask is provided" do - expect { - Hbc::CLI::Uninstall.run("notacask") - }.to raise_error(Hbc::CaskUnavailableError) + expect { Hbc::CLI::Uninstall.run("notacask") } + .to output(/is unavailable/).to_stderr + .and raise_error(Hbc::CaskError, "Uninstall incomplete.") end it "shows an error when a Cask is provided that's not installed" do - expect { - Hbc::CLI::Uninstall.run("local-caffeine") - }.to raise_error(Hbc::CaskNotInstalledError) + expect { Hbc::CLI::Uninstall.run("local-caffeine") } + .to output(/is not installed/).to_stderr + .and raise_error(Hbc::CaskError, "Uninstall incomplete.") end it "tries anyway on a non-present Cask when --force is given" do @@ -89,11 +89,9 @@ describe Hbc::CLI::Uninstall, :cask do Hbc.appdir.join("MyFancyApp.app").rmtree - expect { - shutup do - Hbc::CLI::Uninstall.run("with-uninstall-script-app") - end - }.to raise_error(Hbc::CaskError, /does not exist/) + expect { shutup { Hbc::CLI::Uninstall.run("with-uninstall-script-app") } } + .to output(/does not exist/).to_stderr + .and raise_error(Hbc::CaskError, "Uninstall incomplete.") expect(cask).to be_installed diff --git a/Library/Homebrew/test/cask/cli/zap_spec.rb b/Library/Homebrew/test/cask/cli/zap_spec.rb index f3af0e66f..e39ca61f8 100644 --- a/Library/Homebrew/test/cask/cli/zap_spec.rb +++ b/Library/Homebrew/test/cask/cli/zap_spec.rb @@ -1,8 +1,8 @@ describe Hbc::CLI::Zap, :cask do it "shows an error when a bad Cask is provided" do - expect { - Hbc::CLI::Zap.run("notacask") - }.to raise_error(Hbc::CaskUnavailableError) + expect { Hbc::CLI::Zap.run("notacask") } + .to output(/is unavailable/).to_stderr + .and raise_error(Hbc::CaskError, "Zap incomplete.") end it "can zap and unlink multiple Casks at once" do diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index 7eeabcf49..5849f581b 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -57,7 +57,7 @@ describe Hbc::DSL, :cask do it "raises an error" do expect { cask - }.to raise_error(Hbc::CaskTokenDoesNotMatchError, /Bad header line:.*does not match file name/) + }.to raise_error(Hbc::CaskTokenMismatchError, /header line does not match the file name/) end end diff --git a/Library/Homebrew/test/cask/installer_spec.rb b/Library/Homebrew/test/cask/installer_spec.rb index a32f71cab..8ef82c1d5 100644 --- a/Library/Homebrew/test/cask/installer_spec.rb +++ b/Library/Homebrew/test/cask/installer_spec.rb @@ -145,22 +145,6 @@ describe Hbc::Installer, :cask do expect(with_macosx_dir.staged_path.join("__MACOSX")).not_to be_a_directory end - it "installer method raises an exception when already-installed Casks which auto-update are attempted" do - with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") - - expect(with_auto_updates).not_to be_installed - - installer = Hbc::Installer.new(with_auto_updates) - - shutup do - installer.install - end - - expect { - installer.install - }.to raise_error(Hbc::CaskAlreadyInstalledAutoUpdatesError) - end - it "allows already-installed Casks which auto-update to be installed if force is provided" do with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb") diff --git a/Library/Homebrew/test/cask/verify/checksum_spec.rb b/Library/Homebrew/test/cask/verify/checksum_spec.rb index 55c0e5f44..4b8543d2b 100644 --- a/Library/Homebrew/test/cask/verify/checksum_spec.rb +++ b/Library/Homebrew/test/cask/verify/checksum_spec.rb @@ -1,5 +1,5 @@ describe Hbc::Verify::Checksum, :cask do - let(:cask) { double("cask") } + let(:cask) { double("cask", token: "cask") } let(:downloaded_path) { double("downloaded_path") } let(:verification) { described_class.new(cask, downloaded_path) } |
