diff options
| author | Markus Reiter | 2017-03-05 06:31:36 +0100 | 
|---|---|---|
| committer | Markus Reiter | 2017-03-05 23:08:14 +0100 | 
| commit | 9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch) | |
| tree | 43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/cask/cli/edit_spec.rb | |
| parent | 67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff) | |
| download | brew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2 | |
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/cask/cli/edit_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/cask/cli/edit_spec.rb | 60 | 
1 files changed, 60 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/cli/edit_spec.rb b/Library/Homebrew/test/cask/cli/edit_spec.rb new file mode 100644 index 000000000..61970290b --- /dev/null +++ b/Library/Homebrew/test/cask/cli/edit_spec.rb @@ -0,0 +1,60 @@ +# monkeypatch for testing +module Hbc +  class CLI +    class Edit +      def self.exec_editor(*command) +        editor_commands << command +      end + +      def self.reset! +        @editor_commands = [] +      end + +      def self.editor_commands +        @editor_commands ||= [] +      end +    end +  end +end + +describe Hbc::CLI::Edit, :cask do +  before(:each) do +    Hbc::CLI::Edit.reset! +  end + +  it "opens the editor for the specified Cask" do +    Hbc::CLI::Edit.run("local-caffeine") +    expect(Hbc::CLI::Edit.editor_commands).to eq [ +      [Hbc.path("local-caffeine")], +    ] +  end + +  it "throws away additional arguments and uses the first" do +    Hbc::CLI::Edit.run("local-caffeine", "local-transmission") +    expect(Hbc::CLI::Edit.editor_commands).to eq [ +      [Hbc.path("local-caffeine")], +    ] +  end + +  it "raises an exception when the Cask doesnt exist" do +    expect { +      Hbc::CLI::Edit.run("notacask") +    }.to raise_error(Hbc::CaskUnavailableError) +  end + +  describe "when no Cask is specified" do +    it "raises an exception" do +      expect { +        Hbc::CLI::Edit.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::Edit.run("--notavalidoption") +      }.to raise_error(Hbc::CaskUnspecifiedError) +    end +  end +end  | 
