Merge pull request #2131 from reitermarkus/spec-help

Convert `brew help` test to spec.
This commit is contained in:
Markus Reiter 2017-02-25 06:59:24 +01:00 committed by GitHub
commit 9ca7b351e9
2 changed files with 47 additions and 21 deletions

View File

@ -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

View File

@ -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