Skip to content

Commit

Permalink
fix: correctly handle ignored 'combine' rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 15, 2018
1 parent 4390d16 commit cd52108
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/pact/matching_rules/v3/merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def log_ignored_rules
if @matching_rules.any?
@matching_rules.each do | path, rules_hash |
rules_hash.each do | key, value |
$stderr.puts "WARN: Ignoring unsupported #{key} #{value} for path #{path}" if value.any?
$stderr.puts "WARN: Ignoring unsupported #{key} #{value} for path #{path}" if value_present?(value)
end
end
end
Expand All @@ -129,6 +129,10 @@ def find_rule(path, key)
def log_used_rule path, key, value
@used_rules << [path, key, value]
end

def value_present? value
value.respond_to?(:any?) ? value.any? : true
end
end
end
end
Expand Down
23 changes: 23 additions & 0 deletions spec/lib/pact/matching_rules/v3/merge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,29 @@ module V3
end
end

describe "with a combine key" do
let(:expected) do
{
"foo" => "bar"
}
end

let(:matching_rules) do
{
"$.foo" => {
"matchers" => [{ "match" => "type" }],
"combine" => "AND"
}
}

end

it "logs the ignored rule" do
allow(Pact.configuration.error_stream).to receive(:puts)
expect(Pact.configuration.error_stream).to receive(:puts).with("WARN: Ignoring unsupported combine AND for path $['foo']")
subject
end
end
end
end
end
Expand Down

0 comments on commit cd52108

Please sign in to comment.