Merge pull request #4915 from alexbostock/code-coverage
Improve code coverage
This commit is contained in:
commit
9b667af552
@ -8,4 +8,13 @@ describe "brew cat", :integration_test do
|
|||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@ -6,8 +6,16 @@ describe "brew commands", :integration_test do
|
|||||||
it "prints a list of all available commands" do
|
it "prints a list of all available commands" do
|
||||||
expect { brew "commands" }
|
expect { brew "commands" }
|
||||||
.to output(/Built-in commands/).to_stdout
|
.to output(/Built-in commands/).to_stdout
|
||||||
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
RSpec.shared_context "custom internal commands" do
|
RSpec.shared_context "custom internal commands" do
|
||||||
|
|||||||
@ -1,14 +1,23 @@
|
|||||||
require "cmd/info"
|
require "cmd/info"
|
||||||
|
|
||||||
describe "brew info", :integration_test do
|
describe "brew info", :integration_test do
|
||||||
it "prints information about a given Formula" do
|
before do
|
||||||
setup_test_formula "testball"
|
setup_test_formula "testball"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "prints information about a given Formula" do
|
||||||
expect { brew "info", "testball" }
|
expect { brew "info", "testball" }
|
||||||
.to output(/testball: stable 0.1/).to_stdout
|
.to output(/testball: stable 0.1/).to_stdout
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe Homebrew do
|
describe Homebrew do
|
||||||
|
|||||||
@ -171,3 +171,14 @@ end
|
|||||||
RSpec::Matchers.define_negated_matcher :not_to_output, :output
|
RSpec::Matchers.define_negated_matcher :not_to_output, :output
|
||||||
RSpec::Matchers.alias_matcher :have_failed, :be_failed
|
RSpec::Matchers.alias_matcher :have_failed, :be_failed
|
||||||
RSpec::Matchers.alias_matcher :a_string_containing, :include
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user