Skip to content

Pact Standalone not honoring * matchers #10

@mattermack

Description

@mattermack

The pact standalone does not appear to support the * in JSON path. It does when we explicitly enumerate the items in an array.

Sent - working
Here is what I send to the stand alone:
{ "description": "General Meetup Categories 4", "providerState": "A GET request to return JSON using Meetups category api under version 2 4", "request": { "method": "GET", "headers": { "Content-Type": "application/json" }, "path": "/2/categories" }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "matchingRules": { "$.body.results[1].name": { "match": "regex", "regex": "Games|Book Clubs" }, "$.body.results[1].sort_name": { "match": "regex", "regex": "Games|Book Clubs" }, "$.body.results[1].id": { "match": "type" }, "$.body.results[1].shortname": { "match": "regex", "regex": "Games|Book Clubs" } }, "body": { "results": [ { "name": "Games", "sort_name": "Games", "id": 11, "shortname": "Games" }, { "name": "Book Clubs", "sort_name": "Book Clubs", "id": 18, "shortname": "Book Clubs" } ] } } }

Received - Working
Here is what I get back
{ "description": "General Meetup Categories 4", "providerState": "A GET request to return JSON using Meetups category api under version 2 4", "request": { "method": "GET", "path": "/2/categories", "headers": { "Content-Type": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "results": [ { "name": "Games", "sort_name": "Games", "id": 11, "shortname": "Games" }, { "name": "Book Clubs", "sort_name": "Book Clubs", "id": 18, "shortname": "Book Clubs" } ] }, "matchingRules": { "$.body.results[1].name": { "match": "regex", "regex": "Games|Book Clubs" }, "$.body.results[1].sort_name": { "match": "regex", "regex": "Games|Book Clubs" }, "$.body.results[1].id": { "match": "type" }, "$.body.results[1].shortname": { "match": "regex", "regex": "Games|Book Clubs" } } } }

That works as intended. However, if I add that I want all items in an array to match this pattern [*] instead of [1], matchers are not returned.

Sent - I think with the bug
{ "description": "General Meetup Categories 6", "providerState": "A GET request to return JSON using Meetups category api under version 2 6", "request": { "method": "GET", "headers": { "Content-Type": "application/json" }, "path": "/6/categories" }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "matchingRules": { "$.body.results[*].name": { "match": "regex", "regex": "Games|Book Clubs" }, "$.body.results[*].sort_name": { "match": "regex", "regex": "Games|Book Clubs" }, "$.body.results[*].id": { "match": "type" }, "$.body.results[*].shortname": { "match": "regex", "regex": "Games|Book Clubs" } }, "body": { "results": [ { "name": "Games", "sort_name": "Games", "id": 11, "shortname": "Games" }, { "name": "Book Clubs", "sort_name": "Book Clubs", "id": 18, "shortname": "Book Clubs" } ] } } }

Received - notice no matchers
{ "description": "General Meetup Categories 6", "providerState": "A GET request to return JSON using Meetups category api under version 2 6", "request": { "method": "GET", "path": "/6/categories", "headers": { "Content-Type": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "results": [ { "name": "Games", "sort_name": "Games", "id": 11, "shortname": "Games" }, { "name": "Book Clubs", "sort_name": "Book Clubs", "id": 18, "shortname": "Book Clubs" } ] } } }

This is tested completely outside of PHP or Pact-PHP but with the stand alone Ruby.

  1. Using Postman, delete -> http://localhost:7200/interactions
  2. Using Postman, post-> http://localhost:7200/interactions
  3. Using Postman, get http://localhost:7200/2/categories or http://localhost:7200/6/categories
  4. Using Postman, post http://localhost:7200/pact

Leveraging v1.26.0 on Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions