Move isolated matchers into the specs that uses them

This commit is contained in:
Douglas Eichelberger 2024-03-30 20:06:26 -07:00
parent fde7d380f7
commit 914e53e9d5
3 changed files with 11 additions and 10 deletions

View File

@ -5,6 +5,15 @@ require "cmd/info"
require "cmd/shared_examples/args_parse"
RSpec.describe "brew info" do
RSpec::Matchers.define :a_json_string do
match do |actual|
JSON.parse(actual)
true
rescue JSON::ParserError
false
end
end
it_behaves_like "parseable arguments"
it "prints as json with the --json=v1 flag", :integration_test do

View File

@ -304,16 +304,6 @@ 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|
JSON.parse(actual)
true
rescue JSON::ParserError
false
end
end
# Match consecutive elements in an array.
RSpec::Matchers.define :array_including_cons do |*cons|

View File

@ -3,6 +3,8 @@
require "system_command"
RSpec.describe SystemCommand::Result do
RSpec::Matchers.alias_matcher :a_string_containing, :include
subject(:result) do
described_class.new([], output_array, instance_double(Process::Status, exitstatus: 0, success?: true),
secrets: [])