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

Writing pact file results in non spec v3 compatible matching rules #157

Open
Danny02 opened this issue Mar 12, 2018 · 2 comments
Open

Writing pact file results in non spec v3 compatible matching rules #157

Danny02 opened this issue Mar 12, 2018 · 2 comments
Labels
v3 pact v3 specification

Comments

@Danny02
Copy link

Danny02 commented Mar 12, 2018

I'm using Pact-JS (+pact-js-karma) to test my consumer tests and want to generate Pact files according to version 3 of the Pact spec.
I think that I have set the spec option correctly, because the resulting pact file includes

"metadata": {
    "pactSpecification": {
      "version": "3.0.0"
    }
  }

The generated matching rules are in v2 format:

"$.body._embedded.schuleList[*].*": {
            "match": "type"
 }

Our expectation regarding the generated output according to spec v3 was something like:

"body" : {
"$._embedded.schuleList[*].*": {
    "matchers": [
                {"match": "type" }
     ]       
 }
}
@bethesque
Copy link
Member

Sorry, pact spec v3 is not supported in js yet. Which feature were you particularly interested in?

@YOU54F
Copy link
Member

YOU54F commented Aug 15, 2024

The pact specification is not passed in when pact_mock-service calls the MatchingRules.extract function in pact-support

https://github.com/pact-foundation/pact-support/blob/master/lib/pact/matching_rules.rb#L11

I've added a commit and pull request that will pass the spec version used.

pact-foundation/pact-mock_service#159

however the matching rules are written incorrectly.

pact-message-ruby attempts to correct this here

https://github.com/pact-foundation/pact-message-ruby/blob/8c74b1357333b6c08e801064cc56e61d6ba2049d/lib/pact/message/consumer/interaction_decorator.rb#L50

whereby it would write

      "matchingRules": {
        "body": {
          "$.email": {
            "match": "type"
          },
          "$.first_name": {
            "match": "type"
          }
        }
      }

but it should write

      "matchingRules": {
        "body": {
          "$.email": {
            "matchers": [
              {
                "match": "type"
              }
            ]
          },
          "$.first_name": {
            "matchers": [
              {
                "match": "type"
              }
            ]
          }
        }
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 pact v3 specification
Projects
None yet
Development

No branches or pull requests

3 participants