Add a_json_string matcher and improve tests
This commit is contained in:
parent
e733657f04
commit
122738709a
@ -11,12 +11,11 @@ describe "brew commands", :integration_test do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "prints a list without headers with the --quiet flag" do
|
it "prints a list without headers with the --quiet flag" do
|
||||||
expect { brew "commands", "--quiet" }
|
|
||||||
.to_not output(/Built-in commands/).to_stdout
|
|
||||||
|
|
||||||
expect { brew "commands", "--quiet" }
|
expect { brew "commands", "--quiet" }
|
||||||
.to be_a_success
|
.to be_a_success
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
|
.and not_to_output(/Built-in commands/).to_stdout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ describe "brew info", :integration_test do
|
|||||||
|
|
||||||
it "prints as json with the --json=v1 flag" do
|
it "prints as json with the --json=v1 flag" do
|
||||||
expect { brew "info", "testball", "--json=v1" }
|
expect { brew "info", "testball", "--json=v1" }
|
||||||
.to output(/\{.+testball.+\}/).to_stdout
|
.to output(a_json_string).to_stdout
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
end
|
end
|
||||||
|
|||||||
@ -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