diff options
| author | Ben Muschol | 2017-09-27 16:36:10 -0400 |
|---|---|---|
| committer | GitHub | 2017-09-27 16:36:10 -0400 |
| commit | 2d6bd0400785b5fb061f793f70736f12e6ec8231 (patch) | |
| tree | fd0abc8937fc85fb49714ad9dc4a3735fa58242f /Library/Homebrew/test/cask/cli | |
| parent | fe5c885da0b8b69a5de74647e4181b137acb835f (diff) | |
| parent | cb139ca381cb7f00a4dfdc21482515f103aed417 (diff) | |
| download | brew-2d6bd0400785b5fb061f793f70736f12e6ec8231.tar.bz2 | |
Merge branch 'master' into check-for-master-no-refactor
Diffstat (limited to 'Library/Homebrew/test/cask/cli')
| -rw-r--r-- | Library/Homebrew/test/cask/cli/audit_spec.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/cat_spec.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/create_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/edit_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/fetch_spec.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/info_spec.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/install_spec.rb | 18 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/list_spec.rb | 23 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/search_spec.rb | 53 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/uninstall_spec.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/test/cask/cli/zap_spec.rb | 3 |
11 files changed, 87 insertions, 42 deletions
diff --git a/Library/Homebrew/test/cask/cli/audit_spec.rb b/Library/Homebrew/test/cask/cli/audit_spec.rb index 01f506c8c..30ab437cb 100644 --- a/Library/Homebrew/test/cask/cli/audit_spec.rb +++ b/Library/Homebrew/test/cask/cli/audit_spec.rb @@ -1,8 +1,10 @@ describe Hbc::CLI::Audit, :cask do - let(:cask) { double("cask", token: nil) } + let(:cask) { Hbc::Cask.new(nil) } describe "selection of Casks to audit" do it "audits all Casks if no tokens are given" do + expect(cask).to be_a Hbc::Cask + allow(Hbc).to receive(:all).and_return([cask, cask]) expect(Hbc::Auditor).to receive(:audit).twice.and_return(true) diff --git a/Library/Homebrew/test/cask/cli/cat_spec.rb b/Library/Homebrew/test/cask/cli/cat_spec.rb index b726a0b36..5a4b29c6f 100644 --- a/Library/Homebrew/test/cask/cli/cat_spec.rb +++ b/Library/Homebrew/test/cask/cli/cat_spec.rb @@ -35,8 +35,7 @@ describe Hbc::CLI::Cat, :cask do it "raises an exception when the Cask does not exist" do expect { Hbc::CLI::Cat.run("notacask") } - .to output(/is unavailable/).to_stderr - .and raise_error(Hbc::CaskError, "Cat incomplete.") + .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/create_spec.rb b/Library/Homebrew/test/cask/cli/create_spec.rb index d77b0a2aa..17d426f78 100644 --- a/Library/Homebrew/test/cask/cli/create_spec.rb +++ b/Library/Homebrew/test/cask/cli/create_spec.rb @@ -39,7 +39,7 @@ describe Hbc::CLI::Create, :cask do it "raises an exception when more than one Cask is given" do expect { described_class.run("additional-cask", "another-cask") - }.to raise_error(/Only one Cask can be created at a time./) + }.to raise_error(/Only one Cask can be created at a time\./) end it "raises an exception when the Cask already exists" do diff --git a/Library/Homebrew/test/cask/cli/edit_spec.rb b/Library/Homebrew/test/cask/cli/edit_spec.rb index 5d5cbf4b9..51542807f 100644 --- a/Library/Homebrew/test/cask/cli/edit_spec.rb +++ b/Library/Homebrew/test/cask/cli/edit_spec.rb @@ -12,7 +12,7 @@ describe Hbc::CLI::Edit, :cask do it "raises an error when given more than one argument" do expect { described_class.new("local-caffeine", "local-transmission") - }.to raise_error(/Only one Cask can be created at a time./) + }.to raise_error(/Only one Cask can be edited at a time\./) end it "raises an exception when the Cask doesnt exist" do diff --git a/Library/Homebrew/test/cask/cli/fetch_spec.rb b/Library/Homebrew/test/cask/cli/fetch_spec.rb index f71c23fb6..faaa69b35 100644 --- a/Library/Homebrew/test/cask/cli/fetch_spec.rb +++ b/Library/Homebrew/test/cask/cli/fetch_spec.rb @@ -42,7 +42,7 @@ describe Hbc::CLI::Fetch, :cask do it "properly handles Casks that are not present" do expect { Hbc::CLI::Fetch.run("notacask") - }.to raise_error(Hbc::CaskError, "Fetch incomplete.") + }.to raise_error(Hbc::CaskUnavailableError) end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/info_spec.rb b/Library/Homebrew/test/cask/cli/info_spec.rb index bffe900ec..aec7080de 100644 --- a/Library/Homebrew/test/cask/cli/info_spec.rb +++ b/Library/Homebrew/test/cask/cli/info_spec.rb @@ -10,7 +10,7 @@ describe Hbc::CLI::Info, :cask do ==> Name None ==> Artifacts - Caffeine.app (app) + Caffeine.app (App) EOS end @@ -24,7 +24,7 @@ describe Hbc::CLI::Info, :cask do ==> Name None ==> Artifacts - Caffeine.app (app) + Caffeine.app (App) local-transmission: 2.61 http://example.com/local-transmission Not installed @@ -32,7 +32,7 @@ describe Hbc::CLI::Info, :cask do ==> Name None ==> Artifacts - Transmission.app (app) + Transmission.app (App) EOS } @@ -60,7 +60,7 @@ describe Hbc::CLI::Info, :cask do ==> Name None ==> Artifacts - Caffeine.app (app) + Caffeine.app (App) ==> Caveats Here are some things you might want to know. @@ -86,7 +86,7 @@ describe Hbc::CLI::Info, :cask do ==> Name None ==> Artifacts - Caffeine.app (app) + Caffeine.app (App) EOS end diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb index 64feacce9..e30489789 100644 --- a/Library/Homebrew/test/cask/cli/install_spec.rb +++ b/Library/Homebrew/test/cask/cli/install_spec.rb @@ -56,27 +56,19 @@ describe Hbc::CLI::Install, :cask do it "properly handles Casks that are not present" do expect { Hbc::CLI::Install.run("notacask") - }.to raise_error(Hbc::CaskError, "Install incomplete.") + }.to raise_error(Hbc::CaskUnavailableError) end it "returns a suggestion for a misspelled Cask" do expect { - begin - Hbc::CLI::Install.run("localcaffeine") - rescue Hbc::CaskError - nil - end - }.to output(/Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean:\nlocal-caffeine/).to_stderr + Hbc::CLI::Install.run("localcaffeine") + }.to raise_error(Hbc::CaskUnavailableError, /Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean “local-caffeine”?/) end it "returns multiple suggestions for a Cask fragment" do expect { - begin - Hbc::CLI::Install.run("local-caf") - rescue Hbc::CaskError - nil - end - }.to output(/Cask 'local-caf' is unavailable: No Cask with this name exists\. Did you mean one of:\nlocal-caffeine/).to_stderr + Hbc::CLI::Install.run("local") + }.to raise_error(Hbc::CaskUnavailableError, /Cask 'local' is unavailable: No Cask with this name exists\. Did you mean one of these\?\nlocal-caffeine\nlocal-transmission/) end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb index ecca3035f..d2d7efd3b 100644 --- a/Library/Homebrew/test/cask/cli/list_spec.rb +++ b/Library/Homebrew/test/cask/cli/list_spec.rb @@ -14,6 +14,26 @@ describe Hbc::CLI::List, :cask do EOS end + it "lists full names" do + casks = %w[ + local-caffeine + third-party/tap/third-party-cask + local-transmission + ].map { |c| Hbc::CaskLoader.load(c) } + + casks.each do |c| + InstallHelper.install_with_caskfile(c) + end + + expect { + Hbc::CLI::List.run("--full-name") + }.to output(<<-EOS.undent).to_stdout + local-caffeine + local-transmission + third-party/tap/third-party-cask + EOS + end + describe "lists versions" do let(:casks) { ["local-caffeine", "local-transmission"] } let(:expected_output) { @@ -48,7 +68,8 @@ describe Hbc::CLI::List, :cask do it "lists the installed files for those Casks" do casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile)) - Hbc::Artifact::App.new(transmission).install_phase + Hbc::Artifact::App.for_cask(transmission) + .each { |artifact| artifact.install_phase(command: Hbc::NeverSudoSystemCommand, force: false) } expect { Hbc::CLI::List.run("local-transmission", "local-caffeine") diff --git a/Library/Homebrew/test/cask/cli/search_spec.rb b/Library/Homebrew/test/cask/cli/search_spec.rb index e237ad464..3d58e6a15 100644 --- a/Library/Homebrew/test/cask/cli/search_spec.rb +++ b/Library/Homebrew/test/cask/cli/search_spec.rb @@ -4,6 +4,8 @@ describe Hbc::CLI::Search, :cask do end it "lists the available Casks that match the search term" do + allow(GitHub).to receive(:search_code).and_return([]) + expect { Hbc::CLI::Search.run("local") }.to output(<<-EOS.undent).to_stdout.as_tty @@ -14,6 +16,8 @@ describe Hbc::CLI::Search, :cask do end it "outputs a plain list when stdout is not a TTY" do + allow(GitHub).to receive(:search_code).and_return([]) + expect { Hbc::CLI::Search.run("local") }.to output(<<-EOS.undent).to_stdout @@ -22,16 +26,37 @@ describe Hbc::CLI::Search, :cask do EOS end + it "returns matches even when online search failed" do + allow(GitHub).to receive(:search_code).and_raise(GitHub::Error.new("reason")) + + expect { + Hbc::CLI::Search.run("local") + }.to output(<<-EOS.undent).to_stdout + local-caffeine + local-transmission + EOS + .and output(/^Warning: Error searching on GitHub: reason/).to_stderr + end + it "shows that there are no Casks matching a search term that did not result in anything" do expect { Hbc::CLI::Search.run("foo-bar-baz") - }.to output("No Cask found for \"foo-bar-baz\".\n").to_stdout.as_tty + }.to output(<<-EOS.undent).to_stdout.as_tty + No Cask found for "foo-bar-baz". + EOS end - it "lists all available Casks with no search term" do - expect { - Hbc::CLI::Search.run - }.to output(/local-caffeine/).to_stdout.as_tty + it "doesn't output anything to non-TTY stdout when there are no matches" do + expect { Hbc::CLI::Search.run("foo-bar-baz") } + .to not_to_output.to_stdout + .and not_to_output.to_stderr + end + + it "lists all Casks available offline with no search term" do + allow(GitHub).to receive(:search_code).and_raise(GitHub::Error.new("reason")) + expect { Hbc::CLI::Search.run } + .to output(/local-caffeine/).to_stdout.as_tty + .and not_to_output.to_stderr end it "ignores hyphens in search terms" do @@ -55,19 +80,29 @@ describe Hbc::CLI::Search, :cask do it "accepts a regexp argument" do expect { Hbc::CLI::Search.run("/^local-c[a-z]ffeine$/") - }.to output("==> Regexp Matches\nlocal-caffeine\n").to_stdout.as_tty + }.to output(<<-EOS.undent).to_stdout.as_tty + ==> Regexp Matches + local-caffeine + EOS end - it "Returns both exact and partial matches" do + it "returns both exact and partial matches" do expect { Hbc::CLI::Search.run("test-opera") - }.to output(/^==> Exact Match\ntest-opera\n==> Partial Matches\ntest-opera-mail/).to_stdout.as_tty + }.to output(<<-EOS.undent).to_stdout.as_tty + ==> Exact Match + test-opera + ==> Partial Matches + test-opera-mail + EOS end it "does not search the Tap name" do expect { Hbc::CLI::Search.run("caskroom") - }.to output(/^No Cask found for "caskroom"\.\n/).to_stdout.as_tty + }.to output(<<-EOS.undent).to_stdout.as_tty + No Cask found for "caskroom". + EOS end it "doesn't highlight packages that aren't installed" do diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 1a1c57e88..2ec506839 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -16,14 +16,12 @@ describe Hbc::CLI::Uninstall, :cask do it "shows an error when a bad Cask is provided" do expect { Hbc::CLI::Uninstall.run("notacask") } - .to output(/is unavailable/).to_stderr - .and raise_error(Hbc::CaskError, "Uninstall incomplete.") + .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end it "shows an error when a Cask is provided that's not installed" do expect { Hbc::CLI::Uninstall.run("local-caffeine") } - .to output(/is not installed/).to_stderr - .and raise_error(Hbc::CaskError, "Uninstall incomplete.") + .to raise_error(Hbc::CaskNotInstalledError, /is not installed/) end it "tries anyway on a non-present Cask when --force is given" do @@ -76,8 +74,7 @@ describe Hbc::CLI::Uninstall, :cask do Hbc.appdir.join("MyFancyApp.app").rmtree expect { Hbc::CLI::Uninstall.run("with-uninstall-script-app") } - .to output(/does not exist/).to_stderr - .and raise_error(Hbc::CaskError, "Uninstall incomplete.") + .to raise_error(Hbc::CaskError, /uninstall script .* does not exist/) 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 fdc5b4125..502bf8e69 100644 --- a/Library/Homebrew/test/cask/cli/zap_spec.rb +++ b/Library/Homebrew/test/cask/cli/zap_spec.rb @@ -1,8 +1,7 @@ describe Hbc::CLI::Zap, :cask do it "shows an error when a bad Cask is provided" do expect { Hbc::CLI::Zap.run("notacask") } - .to output(/is unavailable/).to_stderr - .and raise_error(Hbc::CaskError, "Zap incomplete.") + .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end it "can zap and unlink multiple Casks at once" do |
