diff options
| author | Markus Reiter | 2017-10-03 10:49:58 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-10-03 10:56:40 +0200 |
| commit | 643b2a168c6c5b2f21b141ec385fc49d29c41718 (patch) | |
| tree | ae9f32f7283806d2e1878bb4aa8932b2fbacb2de /Library/Homebrew/test/cask/cli/cat_spec.rb | |
| parent | ec0d8fa7ba18f4fe05c5241258502c8db332b13d (diff) | |
| download | brew-643b2a168c6c5b2f21b141ec385fc49d29c41718.tar.bz2 | |
Refactor `cask/cli` specs.
Diffstat (limited to 'Library/Homebrew/test/cask/cli/cat_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/cask/cli/cat_spec.rb | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/Library/Homebrew/test/cask/cli/cat_spec.rb b/Library/Homebrew/test/cask/cli/cat_spec.rb index 5a4b29c6f..6b54a2e4b 100644 --- a/Library/Homebrew/test/cask/cli/cat_spec.rb +++ b/Library/Homebrew/test/cask/cli/cat_spec.rb @@ -1,4 +1,10 @@ +require_relative "shared_examples/requires_cask_token" +require_relative "shared_examples/invalid_option" + describe Hbc::CLI::Cat, :cask do + it_behaves_like "a command that requires a Cask token" + it_behaves_like "a command that handles invalid options" + describe "given a basic Cask" do let(:basic_cask_content) { <<-EOS.undent @@ -16,41 +22,19 @@ describe Hbc::CLI::Cat, :cask do it "displays the Cask file content about the specified Cask" do expect { - Hbc::CLI::Cat.run("basic-cask") + described_class.run("basic-cask") }.to output(basic_cask_content).to_stdout end it "can display multiple Casks" do expect { - Hbc::CLI::Cat.run("basic-cask", "basic-cask") + described_class.run("basic-cask", "basic-cask") }.to output(basic_cask_content * 2).to_stdout end - - it "fails when option is unknown" do - expect { - Hbc::CLI::Cat.run("--notavalidoption", "basic-cask") - }.to raise_error(/invalid option/) - end end it "raises an exception when the Cask does not exist" do - expect { Hbc::CLI::Cat.run("notacask") } + expect { described_class.run("notacask") } .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end - - describe "when no Cask is specified" do - it "raises an exception" do - expect { - Hbc::CLI::Cat.run - }.to raise_error(Hbc::CaskUnspecifiedError) - end - end - - describe "when no Cask is specified, but an invalid option" do - it "raises an exception" do - expect { - Hbc::CLI::Cat.run("--notavalidoption") - }.to raise_error(/invalid option/) - end - end end |
