0

New to pact, but excited to implement at my current 'micro services' based company I generated some reports that compares JSON responses, all done in ruby.

But I am getting stumped by a few keys that are date based and index based.

   Key: - is expected 
        + is actual 
   Matching keys and values are not shown

    {
      "metadata": {
   -    "received_at": "2017-10-23T11:50:12Z"
   +    "received_at": "2017-10-25T01:26:00Z"
      },
      "response": {
        "cascading_avm_results": {
          "automated_valuation": {
   -        "run_date": "2017-10-23",
   -        "internal_run_identifier": "1508784611820479",
   -        "valuation_date": "2017-10-23"
   +        "run_date": "2017-10-25",
   +        "internal_run_identifier": "1508963160085440",
   +        "valuation_date": "2017-10-25"
          }
        }
      }

is there a way to make the provider response ignore it, or modify the output to match those keys?

My understanding, and please correct me if I am wrong, is that we shouldn't stub that provider response on the contract testing right?

Vinchbr
  • 49
  • 4

1 Answers1

0

What you want to do is match the shape of the response, and not specific values. For that you'll need to use flexible matchers - https://github.com/realestate-com-au/pact/wiki/Regular-expressions-and-type-matching-with-Pact.

You can match based on regular expressions, value types etc., including within arrays.

Matthew Fellows
  • 3,669
  • 1
  • 15
  • 18
  • ` "received_at"=># – Vinchbr Oct 26 '17 at 16:45
  • Something doesn't look right there. It may be a bug. Can you recreate the issue using this [repo](https://github.com/pact-foundation/pact-ruby-standalone-e2e-example) if you are using the ruby implementation of pact, or this [repo](https://github.com/pact-foundation/pact-ruby-standalone-e2e-example) if you are using one of the other implementations. Please report the issue in the [pact-support](https://github.com/pact-foundation/pact-support) repository. – Beth Skurrie Oct 26 '17 at 20:53