diff --git a/Library/Homebrew/test/cmd/cat_spec.rb b/Library/Homebrew/test/cmd/cat_spec.rb index 8c230abee2..f88e8b53a4 100644 --- a/Library/Homebrew/test/cmd/cat_spec.rb +++ b/Library/Homebrew/test/cmd/cat_spec.rb @@ -8,4 +8,13 @@ describe "brew cat", :integration_test do .and not_to_output.to_stderr .and be_a_success end + + it "fails when given multiple arguments" do + setup_test_formula "foo" + setup_test_formula "bar" + expect { brew "cat", "foo", "bar" } + .to output(/doesn't support multiple arguments/).to_stderr + .and not_to_output.to_stdout + .and be_a_failure + end end diff --git a/Library/Homebrew/test/cmd/commands_spec.rb b/Library/Homebrew/test/cmd/commands_spec.rb index 07844087f0..5e2ce47dbd 100644 --- a/Library/Homebrew/test/cmd/commands_spec.rb +++ b/Library/Homebrew/test/cmd/commands_spec.rb @@ -6,8 +6,16 @@ describe "brew commands", :integration_test do it "prints a list of all available commands" do expect { brew "commands" } .to output(/Built-in commands/).to_stdout + .and not_to_output.to_stderr .and be_a_success end + + it "prints a list without headers with the --quiet flag" do + expect { brew "commands", "--quiet" } + .to be_a_success + .and not_to_output.to_stderr + .and not_to_output(/Built-in commands/).to_stdout + end end RSpec.shared_context "custom internal commands" do diff --git a/Library/Homebrew/test/cmd/info_spec.rb b/Library/Homebrew/test/cmd/info_spec.rb index 8deef3d23b..2d091de2ed 100644 --- a/Library/Homebrew/test/cmd/info_spec.rb +++ b/Library/Homebrew/test/cmd/info_spec.rb @@ -1,14 +1,23 @@ require "cmd/info" describe "brew info", :integration_test do - it "prints information about a given Formula" do + before do setup_test_formula "testball" + end + it "prints information about a given Formula" do expect { brew "info", "testball" } .to output(/testball: stable 0.1/).to_stdout .and not_to_output.to_stderr .and be_a_success end + + it "prints as json with the --json=v1 flag" do + expect { brew "info", "testball", "--json=v1" } + .to output(a_json_string).to_stdout + .and not_to_output.to_stderr + .and be_a_success + end end describe Homebrew do diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 20bdf95983..c084b1e551 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -171,3 +171,14 @@ end RSpec::Matchers.define_negated_matcher :not_to_output, :output RSpec::Matchers.alias_matcher :have_failed, :be_failed RSpec::Matchers.alias_matcher :a_string_containing, :include + +RSpec::Matchers.define :a_json_string do + match do |actual| + begin + JSON.parse(actual) + true + rescue JSON::ParseError + false + end + end +end