Skip to content

Commit 6306693

Browse files
committed
feat: include interaction diffs in verification response
cc: @TimothyJones
1 parent c372104 commit 6306693

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/pact/mock_service/interactions/verification.rb

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def missing_interactions
3838
expected_interactions - actual_interactions.matched_interactions - @actual_interactions.interaction_mismatches.collect(&:candidate_interactions).flatten
3939
end
4040

41+
def interaction_mismatches
42+
actual_interactions.interaction_mismatches
43+
end
44+
4145
private
4246

4347
attr_reader :expected_interactions, :actual_interactions

lib/pact/mock_service/request_handlers/verification_get.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def initialize verification
5252
def to_s
5353
titles_and_summaries.collect do | title, summaries |
5454
"#{title}:\n\t#{summaries.join("\n\t")}\n\n" if summaries.any?
55-
end.compact.join
55+
end.compact.join + verification.interaction_mismatches.collect(&:to_s).join("\n\n") + "\n"
5656

5757
end
5858

spec/lib/pact/consumer/mock_service/verification_get_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ module RequestHandlers
105105
describe "FailureMessage" do
106106
let(:missing_interactions_summaries) { ["Blah", "Thing"]}
107107
let(:interaction_mismatches_summaries) { []}
108+
let(:interaction_mismatches) { []}
108109
let(:unexpected_requests_summaries) { []}
109110
let(:verification) { instance_double("Pact::Consumer::Verification") }
110111
subject { VerificationGet::FailureMessage.new(verification).to_s }
111112

112113
before do
113114
allow(verification).to receive(:missing_interactions_summaries).and_return(missing_interactions_summaries)
114115
allow(verification).to receive(:interaction_mismatches_summaries).and_return(interaction_mismatches_summaries)
116+
allow(verification).to receive(:interaction_mismatches).and_return(interaction_mismatches)
115117
allow(verification).to receive(:unexpected_requests_summaries).and_return(unexpected_requests_summaries)
116118
end
117119

@@ -122,6 +124,7 @@ module RequestHandlers
122124
\tBlah
123125
\tThing
124126
127+
125128
EOS
126129
}
127130
it "only includes missing interactions" do
@@ -132,6 +135,7 @@ module RequestHandlers
132135
context "with missing, mismatches and unexpected interactions" do
133136

134137
let(:interaction_mismatches_summaries) { ["wiffle"]}
138+
let(:interaction_mismatches) { ["diffs"]}
135139
let(:unexpected_requests_summaries) { ["moose"]}
136140

137141
let(:expected_string) { <<-EOS
@@ -145,6 +149,7 @@ module RequestHandlers
145149
Unexpected requests:
146150
\tmoose
147151
152+
diffs
148153
EOS
149154
}
150155
it "includes all the things" do

0 commit comments

Comments
 (0)