aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-23 06:05:26 +0100
committerMarkus Reiter2017-02-23 21:11:02 +0100
commitc37dbb79b669fc0c4088415d7269a6618f1ccb3c (patch)
treefba2ac4e433ad7e7bc14554a0780eb4a6a5b738e /Library
parentc7121f6be50e44784e3e29114617c29715bd9c0f (diff)
downloadbrew-c37dbb79b669fc0c4088415d7269a6618f1ccb3c.tar.bz2
Convert `brew help` test to spec.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/cmd/help_spec.rb47
-rw-r--r--Library/Homebrew/test/help_test.rb21
2 files changed, 47 insertions, 21 deletions
diff --git a/Library/Homebrew/test/cmd/help_spec.rb b/Library/Homebrew/test/cmd/help_spec.rb
new file mode 100644
index 000000000..6d94d7444
--- /dev/null
+++ b/Library/Homebrew/test/cmd/help_spec.rb
@@ -0,0 +1,47 @@
+describe "brew", :integration_test do
+ it "prints help when no argument is given" do
+ expect { brew }
+ .to output(/Example usage:\n/).to_stderr
+ .and be_a_failure
+ end
+
+ describe "help" do
+ it "prints help" do
+ expect { brew "help" }
+ .to output(/Example usage:\n/).to_stdout
+ .and be_a_success
+ end
+
+ it "prints help for a documented Ruby command" do
+ expect { brew "help", "cat" }
+ .to output(/^brew cat/).to_stdout
+ .and be_a_success
+ end
+
+ it "prints help for a documented shell command" do
+ expect { brew "help", "update" }
+ .to output(/^brew update/).to_stdout
+ .and be_a_success
+ end
+
+ it "prints help for a documented Ruby developer command" do
+ expect { brew "help", "update-test" }
+ .to output(/^brew update-test/).to_stdout
+ .and be_a_success
+ end
+
+ it "fails when given an unknown command" do
+ expect { brew "help", "command-that-does-not-exist" }
+ .to output(/Unknown command: command-that-does-not-exist/).to_stderr
+ .and be_a_failure
+ end
+ end
+
+ describe "cat" do
+ it "prints help when no argument is given" do
+ expect { brew "cat" }
+ .to output(/^brew cat/).to_stderr
+ .and be_a_failure
+ end
+ end
+end
diff --git a/Library/Homebrew/test/help_test.rb b/Library/Homebrew/test/help_test.rb
deleted file mode 100644
index 92dd99721..000000000
--- a/Library/Homebrew/test/help_test.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require "testing_env"
-
-class IntegrationCommandTestHelp < IntegrationCommandTestCase
- def test_help
- assert_match "Example usage:\n",
- cmd_fail # Generic help (empty argument list).
- assert_match "Unknown command: command-that-does-not-exist",
- cmd_fail("help", "command-that-does-not-exist")
- assert_match(/^brew cat /,
- cmd_fail("cat")) # Missing formula argument triggers help.
-
- assert_match "Example usage:\n",
- cmd("help") # Generic help.
- assert_match(/^brew cat /,
- cmd("help", "cat")) # Internal command (documented, Ruby).
- assert_match(/^brew update /,
- cmd("help", "update")) # Internal command (documented, Shell).
- assert_match(/^brew update-test /,
- cmd("help", "update-test")) # Internal developer command (documented, Ruby).
- end
-end