Skip to content

Commit

Permalink
feat: include interaction diffs in verification response
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Feb 25, 2021
1 parent c372104 commit 6306693
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/pact/mock_service/interactions/verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def missing_interactions
expected_interactions - actual_interactions.matched_interactions - @actual_interactions.interaction_mismatches.collect(&:candidate_interactions).flatten
end

def interaction_mismatches
actual_interactions.interaction_mismatches
end

private

attr_reader :expected_interactions, :actual_interactions
Expand Down
2 changes: 1 addition & 1 deletion lib/pact/mock_service/request_handlers/verification_get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def initialize verification
def to_s
titles_and_summaries.collect do | title, summaries |
"#{title}:\n\t#{summaries.join("\n\t")}\n\n" if summaries.any?
end.compact.join
end.compact.join + verification.interaction_mismatches.collect(&:to_s).join("\n\n") + "\n"

end

Expand Down
5 changes: 5 additions & 0 deletions spec/lib/pact/consumer/mock_service/verification_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ module RequestHandlers
describe "FailureMessage" do
let(:missing_interactions_summaries) { ["Blah", "Thing"]}
let(:interaction_mismatches_summaries) { []}
let(:interaction_mismatches) { []}
let(:unexpected_requests_summaries) { []}
let(:verification) { instance_double("Pact::Consumer::Verification") }
subject { VerificationGet::FailureMessage.new(verification).to_s }

before do
allow(verification).to receive(:missing_interactions_summaries).and_return(missing_interactions_summaries)
allow(verification).to receive(:interaction_mismatches_summaries).and_return(interaction_mismatches_summaries)
allow(verification).to receive(:interaction_mismatches).and_return(interaction_mismatches)
allow(verification).to receive(:unexpected_requests_summaries).and_return(unexpected_requests_summaries)
end

Expand All @@ -122,6 +124,7 @@ module RequestHandlers
\tBlah
\tThing
EOS
}
it "only includes missing interactions" do
Expand All @@ -132,6 +135,7 @@ module RequestHandlers
context "with missing, mismatches and unexpected interactions" do

let(:interaction_mismatches_summaries) { ["wiffle"]}
let(:interaction_mismatches) { ["diffs"]}
let(:unexpected_requests_summaries) { ["moose"]}

let(:expected_string) { <<-EOS
Expand All @@ -145,6 +149,7 @@ module RequestHandlers
Unexpected requests:
\tmoose
diffs
EOS
}
it "includes all the things" do
Expand Down

0 comments on commit 6306693

Please sign in to comment.