From 9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 5 Mar 2017 06:31:36 +0100 Subject: Move Cask specs into `brew tests`. --- Library/Homebrew/test/cask/cli/edit_spec.rb | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Library/Homebrew/test/cask/cli/edit_spec.rb (limited to 'Library/Homebrew/test/cask/cli/edit_spec.rb') 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 -- cgit v1.2.3