Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: diffs are wrapped in :body when passed for formatting #2

Merged

Conversation

uldissturms
Copy link
Contributor

@uldissturms uldissturms commented Jul 23, 2018

The issue seems to be with diffs passed in a wrapped object {:body => diffs}, e.g.,

{:body=>[#<Pact::Matchers::Difference:0x007fb72e59cfa8 @expected="bar", @actual="WIFFLE", @message="Expected attribute bar but got WIFFLE at $.foo.thing.@name">]}

It's probably best to remove this knowledge from differ if possible and rely on array being passed in instead of a specific hash. Anyways, this seems to work when integrated with pact-ruby (pact-ruby-e2e-example).

Excerpt from logs:

# cat bar_mock_service.log
E, [2018-07-23T20:39:49.521404 #72173] ERROR -- : No matching interaction found for POST /thing
E, [2018-07-23T20:39:49.521453 #72173] ERROR -- : Interaction diffs for that route:
E, [2018-07-23T20:39:49.523228 #72173] ERROR -- : Diff with interaction: "a retrieve thing request"
EXPECTED : bar
ACTUAL   : WIFFLE
MESSAGE  : Expected attribute bar but got WIFFLE at $.foo.thing.@name
# cat bar_spec.rb
+ expect(bar_response.body).to eql ({})
expect(bar_response.status).to eql 201

Mock server response on error now resembles that of JSON:

{
  "message": "No interaction found for POST /thing",
  "interaction_diffs": [
    {
      "description": "a retrieve thing request",
      "body": [
        {
          "EXPECTED": "bar",
          "ACTUAL": "WIFFLE"
        }
      ]
    }
  ]
}

@bethesque bethesque merged commit 45769ce into pact-foundation:master Jul 23, 2018
@bethesque
Copy link
Member

I'm going to have to modify the diff response, because that response isn't very helpful is it!

@uldissturms uldissturms deleted the fix/diff-formatting-for-body branch July 24, 2018 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants