Skip to content

Commit cd52108

Browse files
committedNov 15, 2018
fix: correctly handle ignored 'combine' rule
Fixes: pact-foundation/pact-ruby-standalone#25
1 parent 4390d16 commit cd52108

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
 

‎lib/pact/matching_rules/v3/merge.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def log_ignored_rules
116116
if @matching_rules.any?
117117
@matching_rules.each do | path, rules_hash |
118118
rules_hash.each do | key, value |
119-
$stderr.puts "WARN: Ignoring unsupported #{key} #{value} for path #{path}" if value.any?
119+
$stderr.puts "WARN: Ignoring unsupported #{key} #{value} for path #{path}" if value_present?(value)
120120
end
121121
end
122122
end
@@ -129,6 +129,10 @@ def find_rule(path, key)
129129
def log_used_rule path, key, value
130130
@used_rules << [path, key, value]
131131
end
132+
133+
def value_present? value
134+
value.respond_to?(:any?) ? value.any? : true
135+
end
132136
end
133137
end
134138
end

‎spec/lib/pact/matching_rules/v3/merge_spec.rb

+23
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,29 @@ module V3
456456
end
457457
end
458458

459+
describe "with a combine key" do
460+
let(:expected) do
461+
{
462+
"foo" => "bar"
463+
}
464+
end
465+
466+
let(:matching_rules) do
467+
{
468+
"$.foo" => {
469+
"matchers" => [{ "match" => "type" }],
470+
"combine" => "AND"
471+
}
472+
}
473+
474+
end
475+
476+
it "logs the ignored rule" do
477+
allow(Pact.configuration.error_stream).to receive(:puts)
478+
expect(Pact.configuration.error_stream).to receive(:puts).with("WARN: Ignoring unsupported combine AND for path $['foo']")
479+
subject
480+
end
481+
end
459482
end
460483
end
461484
end

0 commit comments

Comments
 (0)
Please sign in to comment.