aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/cli/edit_spec.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-05 23:31:21 +0100
committerGitHub2017-03-05 23:31:21 +0100
commit1fbd720e3558934f8050385e31e1fec4e7ead982 (patch)
tree13d5867932f5b61ce16335e2bb04ab428ba76f77 /Library/Homebrew/test/cask/cli/edit_spec.rb
parent67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff)
parenteed5a69a51966f53068af7117483f9fd681346fa (diff)
downloadbrew-1fbd720e3558934f8050385e31e1fec4e7ead982.tar.bz2
Merge pull request #2260 from reitermarkus/spec-cask
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.rb60
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