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

Matching rules against field name with a '@' character are not working #162

Open
tienvx opened this issue Jul 11, 2020 · 1 comment
Open

Comments

@tienvx
Copy link
Contributor

tienvx commented Jul 11, 2020

Hi,

I would like to use the code as mock on consumer:


        // build the request
        $request = new ConsumerRequest();
        $request
            ->setMethod('POST')
            ->setPath('/api/books')
            ->addHeader('Content-Type', 'application/json')
            ->setBody([
                'isbn' => $this->matcher->like('0099740915'),
                'title' => $this->matcher->like("The Handmaid's Tale"),
                'description' => $this->matcher->like('Brilliantly conceived and executed, this powerful evocation of twenty-first century America gives full rein to Margaret Atwood\'s devastating irony, wit and astute perception.'),
                'author' => $this->matcher->like('Margaret Atwood'),
                'publicationDate' => $this->matcher->like('1985-07-31T00:00:00+00:00'),
            ]);

        // build the response
        $response = new ProviderResponse();
        $response
            ->setStatus(201)
            ->addHeader('Content-Type', 'application/ld+json; charset=utf-8')
            ->setBody([
                '@context' => '/api/contexts/Book',
                '@id' => $this->matcher->term('/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6', '^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$'),
                '@type' => 'Book',
                'title' => $this->matcher->like('Voluptas et tempora repellat corporis excepturi.'),
                'description' => $this->matcher->like('Quaerat odit quia nisi accusantium natus voluptatem. Explicabo corporis eligendi ut ut sapiente ut qui quidem. Optio amet velit aut delectus. Sed alias asperiores perspiciatis deserunt omnis. Mollitia unde id in.'),
                'author' => $this->matcher->like('Melisa Kassulke'),
                'publicationDate' => $this->matcher->dateTimeISO8601('1999-02-13T00:00:00+07:00'),
                'reviews' => [],
           ]);

        $this->builder->given('Book Fixtures Loaded')
            ->uponReceiving('A POST request to create book')
            ->with($request)
            ->willRespondWith($response);

It works fine on consumer, but on provider, it does not pass. Here is the results on CI:

Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example

       Actual: {"@context":"/api/contexts/Book","@id":"/api/books/eea415c8-da50-4b24-ba2f-2e4ac1d012b4","@type":"Book","isbn":"0099740915","title":"The Handmaid's Tale","description":"Brilliantly conceived and executed, this powerful evocation of twenty-first century America gives full rein to Margaret Atwood's devastating irony, wit and astute perception.","author":"Margaret Atwood","publicationDate":"1985-07-31T00:00:00+00:00","reviews":[]}

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

        {
       -  "@id": "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6"
       +  "@id": "/api/books/eea415c8-da50-4b24-ba2f-2e4ac1d012b4"
       

       Description of differences
       --------------------------------------
       * Expected "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6" but got "/api/books/eea415c8-da50-4b24-ba2f-2e4ac1d012b4" at $.@id

Also, there is a warning on CI:

WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']@['id']

I noticed that the character @ is not going along with id.

Here are details information:

From Github Actions

2020-07-11T07:43:32.8179985Z [2020-07-11T07:43:32.816817+00:00] console.INFO: Verifying PACT with script:
2020-07-11T07:43:32.8182446Z /__w/contract-provider-example/contract-provider-example/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Installer/../../../../pact/bin/pact-provider-verifier ***/pacts/provider/BookStore/consumer/BookPublisher/version/1.0.0 ***/pacts/provider/BookStore/consumer/BookRating/version/1.0.0 --provider-base-url=http://127.0.0.1:8000 --provider-app-version=1.0.0 --provider-states-setup-url=http://127.0.0.1:8000/states-setup --publish-verification-results --broker-token=*** --provider=BookStore --log-dir=./tests/_output
2020-07-11T07:43:32.8182802Z 
2020-07-11T07:43:32.8182990Z  [] []
2020-07-11T07:43:32.8184926Z [2020-07-11T07:43:32.817414+00:00] console.DEBUG: Process command: /__w/contract-provider-example/contract-provider-example/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Installer/../../../../pact/bin/pact-provider-verifier ***/pacts/provider/BookStore/consumer/BookPublisher/version/1.0.0 ***/pacts/provider/BookStore/consumer/BookRating/version/1.0.0 --provider-base-url=http://127.0.0.1:8000 --provider-app-version=1.0.0 --provider-states-setup-url=http://127.0.0.1:8000/states-setup --publish-verification-results --broker-token=*** --provider=BookStore --log-dir=./tests/_output [] []
2020-07-11T07:43:45.5445268Z [2020-07-11T07:43:45.543975+00:00] console.DEBUG: Exit code: 1 [] []
2020-07-11T07:43:45.5453992Z 
2020-07-11T07:43:45.5455561Z [2020-07-11T07:43:45.544834+00:00] console.INFO: out > INFO: Reading pact at ***/pacts/provider/BookStore/consumer/BookPublisher/version/1.0.0
2020-07-11T07:43:45.5456568Z 
2020-07-11T07:43:45.5456948Z Verifying a pact between BookPublisher and BookStore
2020-07-11T07:43:45.5457306Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5457656Z     A POST request to create book
2020-07-11T07:43:45.5458001Z       with POST /api/books
2020-07-11T07:43:45.5460049Z In ProcessRunner.php line 132:
2020-07-11T07:43:45.5460536Z         returns a response which
2020-07-11T07:43:45.5461164Z           has status code 201
2020-07-11T07:43:45.5461412Z                                                   
2020-07-11T07:43:45.5461988Z   PactPHP Process returned non-zero exit code: 1  
2020-07-11T07:43:45.5462173Z                                                   
2020-07-11T07:43:45.5462287Z 
2020-07-11T07:43:45.5462607Z           has a matching body (FAILED - 1)
2020-07-11T07:43:45.5462836Z           includes headers
2020-07-11T07:43:45.5463215Z             "Content-Type" which equals "application/ld+json; charset=utf-8"
2020-07-11T07:43:45.5463433Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5463610Z     A PUT request to generate book cover
2020-07-11T07:43:45.5464002Z       with PUT /api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6/generate-cover
2020-07-11T07:43:45.5464195Z         returns a response which
2020-07-11T07:43:45.5464365Z           has status code 204
2020-07-11T07:43:45.5464454Z 
2020-07-11T07:43:45.5464611Z Failures:
2020-07-11T07:43:45.5464712Z 
2020-07-11T07:43:45.5464977Z   1) Verifying a pact between BookPublisher and BookStore Given Book Fixtures Loaded A POST request to create book with POST /api/books returns a response which has a matching body
2020-07-11T07:43:45.5465241Z      Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example
2020-07-11T07:43:45.5465376Z 
2020-07-11T07:43:45.5466254Z        Actual: {"@context":"/api/contexts/Book","@id":"/api/books/eea415c8-da50-4b24-ba2f-2e4ac1d012b4","@type":"Book","isbn":"0099740915","title":"The Handmaid's Tale","description":"Brilliantly conceived and executed, this powerful evocation of twenty-first century America gives full rein to Margaret Atwood's devastating irony, wit and astute perception.","author":"Margaret Atwood","publicationDate":"1985-07-31T00:00:00+00:00","reviews":[]}
2020-07-11T07:43:45.5466484Z 
2020-07-11T07:43:45.5466639Z        Diff
2020-07-11T07:43:45.5466972Z        --------------------------------------
2020-07-11T07:43:45.5467312Z        Key: �[31m-�[0m�[31m is expected 
2020-07-11T07:43:45.5467647Z        �[0m�[32m     +�[0m�[32m is actual 
2020-07-11T07:43:45.5467984Z        �[0mMatching keys and values are not shown
2020-07-11T07:43:45.5468080Z 
2020-07-11T07:43:45.5468360Z        �[0m {
2020-07-11T07:43:45.5468735Z        �[31m-  "@id": "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6"
2020-07-11T07:43:45.5469140Z        �[0m�[32m+  "@id": "/api/books/eea415c8-da50-4b24-ba2f-2e4ac1d012b4"
2020-07-11T07:43:45.5469443Z        �[0m
2020-07-11T07:43:45.5469541Z 
2020-07-11T07:43:45.5469708Z        Description of differences
2020-07-11T07:43:45.5470042Z        --------------------------------------
2020-07-11T07:43:45.5470528Z        * Expected "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6" but got "/api/books/eea415c8-da50-4b24-ba2f-2e4ac1d012b4" at $.@id
2020-07-11T07:43:45.5470657Z 
2020-07-11T07:43:45.5470818Z 2 interactions, 1 failure
2020-07-11T07:43:45.5470920Z 
2020-07-11T07:43:45.5471205Z Failed interactions:
2020-07-11T07:43:45.5471297Z 
2020-07-11T07:43:45.5471465Z * A post request to create book given Book Fixtures Loaded
2020-07-11T07:43:45.5472533Z INFO: Verification results published to ***/pacts/provider/BookStore/consumer/BookPublisher/pact-version/e3b8757e0adc325edd21c6aa411ad36272bf5169/verification-results/160
2020-07-11T07:43:45.5472691Z 
2020-07-11T07:43:45.5473377Z INFO: Reading pact at ***/pacts/provider/BookStore/consumer/BookRating/version/1.0.0
2020-07-11T07:43:45.5473512Z 
2020-07-11T07:43:45.5473683Z Verifying a pact between BookRating and BookStore
2020-07-11T07:43:45.5474075Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5474255Z     A GET request to get books at page 1
2020-07-11T07:43:45.5474429Z       with GET /api/books?page=1
2020-07-11T07:43:45.5474599Z         returns a response which
2020-07-11T07:43:45.5474768Z           has status code 200
2020-07-11T07:43:45.5475124Z           has a matching body (FAILED - 1)
2020-07-11T07:43:45.5475300Z           includes headers
2020-07-11T07:43:45.5475770Z             "Content-Type" which equals "application/ld+json; charset=utf-8"
2020-07-11T07:43:45.5475970Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5476140Z     A GET request to get review
2020-07-11T07:43:45.5476520Z       with GET /api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500
2020-07-11T07:43:45.5476704Z         returns a response which
2020-07-11T07:43:45.5476875Z           has status code 200
2020-07-11T07:43:45.5477203Z           has a matching body (FAILED - 2)
2020-07-11T07:43:45.5477377Z           includes headers
2020-07-11T07:43:45.5477754Z             "Content-Type" which equals "application/ld+json; charset=utf-8"
2020-07-11T07:43:45.5477941Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5478117Z     A GET request to get books at page 2
2020-07-11T07:43:45.5478293Z       with GET /api/books?page=2
2020-07-11T07:43:45.5478463Z         returns a response which
2020-07-11T07:43:45.5478690Z           has status code 200
2020-07-11T07:43:45.5479018Z           has a matching body (FAILED - 3)
2020-07-11T07:43:45.5479189Z           includes headers
2020-07-11T07:43:45.5479554Z             "Content-Type" which equals "application/ld+json; charset=utf-8"
2020-07-11T07:43:45.5479739Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5479909Z     A GET request to get books at page 3
2020-07-11T07:43:45.5480082Z       with GET /api/books?page=3
2020-07-11T07:43:45.5480248Z         returns a response which
2020-07-11T07:43:45.5480416Z           has status code 200
2020-07-11T07:43:45.5480739Z           has a matching body (FAILED - 4)
2020-07-11T07:43:45.5480918Z           includes headers
2020-07-11T07:43:45.5481282Z             "Content-Type" which equals "application/ld+json; charset=utf-8"
2020-07-11T07:43:45.5481469Z   Given Book Fixtures Loaded
2020-07-11T07:43:45.5481642Z     A GET request to get books at page 4
2020-07-11T07:43:45.5481814Z       with GET /api/books?page=4
2020-07-11T07:43:45.5481984Z         returns a response which
2020-07-11T07:43:45.5482297Z           has status code 200
2020-07-11T07:43:45.5482471Z           has a matching body
2020-07-11T07:43:45.5482641Z           includes headers
2020-07-11T07:43:45.5483021Z             "Content-Type" which equals "application/ld+json; charset=utf-8"
2020-07-11T07:43:45.5483144Z 
2020-07-11T07:43:45.5483301Z Failures:
2020-07-11T07:43:45.5483385Z 
2020-07-11T07:43:45.5483603Z   1) Verifying a pact between BookRating and BookStore Given Book Fixtures Loaded A GET request to get books at page 1 with GET /api/books?page=1 returns a response which has a matching body
2020-07-11T07:43:45.5483865Z      Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example
2020-07-11T07:43:45.5483994Z 
2020-07-11T07:43:45.5487651Z        Actual: {"@context":"/api/contexts/Book","@id":"/api/books","@type":"hydra:Collection","hydra:member":[{"@id":"/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6","@type":"Book","isbn":"9791682873488","title":"Id nemo dignissimos magni ea molestiae repellat omnis laborum.","description":"Assumenda ea aperiam quidem natus. Magnam quam incidunt cupiditate. Ut iusto magnam sint architecto quisquam et laboriosam.","author":"Mr. Harold Thiel Sr.","publicationDate":"1971-09-15T00:00:00+00:00","reviews":[{"@id":"/api/reviews/90bee04e-445c-405a-ba9d-b3a0fcccb7f4","@type":"http://schema.org/Review","body":"Omnis voluptatem at iusto in libero saepe ab. Quidem adipisci nobis enim explicabo officiis at. Praesentium minima qui vitae cupiditate consectetur et est iure. Ullam sit minima sint et natus perferendis officia. Aut exercitationem facere dolores praesentium ut commodi iusto."}]},{"@id":"/api/books/04eb2d56-b240-4cec-b48f-83b7276d6e3e","@type":"Book","isbn":"9793840078278","title":"Maxime quaerat asperiores tenetur at et repellendus non sint.","description":"Delectus occaecati sit incidunt voluptatem ea dolor odit. Autem consequuntur et et esse consequatur.","author":"Liana D'Amore","publicationDate":"1993-10-18T00:00:00+00:00","reviews":[]}],"hydra:totalItems":8,"hydra:view":{"@id":"/api/books?page=1","@type":"hydra:PartialCollectionView","hydra:first":"/api/books?page=1","hydra:last":"/api/books?page=4","hydra:next":"/api/books?page=2"},"hydra:search":{"@type":"hydra:IriTemplate","hydra:template":"/api/books{?properties[],order[id],order[title],order[author],order[isbn],order[publicationDate],title,author}","hydra:variableRepresentation":"BasicRepresentation","hydra:mapping":[{"@type":"IriTemplateMapping","variable":"properties[]","property":null,"required":false},{"@type":"IriTemplateMapping","variable":"order[id]","property":"id","required":false},{"@type":"IriTemplateMapping","variable":"order[title]","property":"title","required":false},{"@type":"IriTemplateMapping","variable":"order[author]","property":"author","required":false},{"@type":"IriTemplateMapping","variable":"order[isbn]","property":"isbn","required":false},{"@type":"IriTemplateMapping","variable":"order[publicationDate]","property":"publicationDate","required":false},{"@type":"IriTemplateMapping","variable":"title","property":"title","required":false},{"@type":"IriTemplateMapping","variable":"author","property":"author","required":false}]}}
2020-07-11T07:43:45.5488469Z 
2020-07-11T07:43:45.5488633Z        Diff
2020-07-11T07:43:45.5488995Z        --------------------------------------
2020-07-11T07:43:45.5489331Z        Key: �[31m-�[0m�[31m is expected 
2020-07-11T07:43:45.5489661Z        �[0m�[32m     +�[0m�[32m is actual 
2020-07-11T07:43:45.5490005Z        �[0mMatching keys and values are not shown
2020-07-11T07:43:45.5490100Z 
2020-07-11T07:43:45.5490407Z        �[0m   "hydra:member": [
2020-07-11T07:43:45.5490584Z             ... ,
2020-07-11T07:43:45.5490747Z             {
2020-07-11T07:43:45.5491053Z        �[31m-      "reviews": [
2020-07-11T07:43:45.5491357Z        �[0m�[31m-        {
2020-07-11T07:43:45.5491755Z        �[0m�[31m-          "@id": "/api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500",
2020-07-11T07:43:45.5492156Z        �[0m�[31m-          "@type": "http://schema.org/Review",
2020-07-11T07:43:45.5492853Z        �[0m�[31m-          "body": "Necessitatibus eius commodi odio ut aliquid. Sit enim molestias in minus aliquid repudiandae qui. Distinctio modi officiis eos suscipit. Vel ut modi quia recusandae qui eligendi. Voluptas totam asperiores ab tenetur voluptatem repudiandae reiciendis."
2020-07-11T07:43:45.5493232Z        �[0m�[31m-        },
2020-07-11T07:43:45.5493552Z        �[0m�[32m+      "reviews": [,
2020-07-11T07:43:45.5493846Z        �[0m�[32m+
2020-07-11T07:43:45.5494136Z        �[0m       ]
2020-07-11T07:43:45.5494319Z             }
2020-07-11T07:43:45.5494479Z           ]
2020-07-11T07:43:45.5494570Z 
2020-07-11T07:43:45.5494732Z        Description of differences
2020-07-11T07:43:45.5495105Z        --------------------------------------
2020-07-11T07:43:45.5495314Z        * Actual array is too short and should have contained a Hash at $.hydra:member[1].reviews[0]
2020-07-11T07:43:45.5495442Z 
2020-07-11T07:43:45.5496246Z   2) Verifying a pact between BookRating and BookStore Given Book Fixtures Loaded A GET request to get review with GET /api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500 returns a response which has a matching body
2020-07-11T07:43:45.5496526Z      Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example
2020-07-11T07:43:45.5496639Z 
2020-07-11T07:43:45.5497560Z        Actual: {"@context":"/api/contexts/Review","@id":"/api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500","@type":"http://schema.org/Review","body":"Sed totam a odio reiciendis totam. Vitae illum aut ea minima. Velit quo velit ut ut et ea est.","rating":0,"book":{"@id":"/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6","@type":"Book","title":"Enim laborum repellendus eos repellat velit."},"author":"Dr. Marianna Wiza","publicationDate":"1994-02-17T12:38:00+00:00"}
2020-07-11T07:43:45.5497881Z 
2020-07-11T07:43:45.5498037Z        Diff
2020-07-11T07:43:45.5498376Z        --------------------------------------
2020-07-11T07:43:45.5498716Z        Key: �[31m-�[0m�[31m is expected 
2020-07-11T07:43:45.5499109Z        �[0m�[32m     +�[0m�[32m is actual 
2020-07-11T07:43:45.5499459Z        �[0mMatching keys and values are not shown
2020-07-11T07:43:45.5499572Z 
2020-07-11T07:43:45.5499851Z        �[0m {
2020-07-11T07:43:45.5500015Z           "book": {
2020-07-11T07:43:45.5500393Z        �[31m-    "@id": "/api/books/1b45e925-318a-4e8b-a53b-e5fe37a6454d"
2020-07-11T07:43:45.5500801Z        �[0m�[32m+    "@id": "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6"
2020-07-11T07:43:45.5501162Z        �[0m
2020-07-11T07:43:45.5501248Z 
2020-07-11T07:43:45.5501411Z        Description of differences
2020-07-11T07:43:45.5501749Z        --------------------------------------
2020-07-11T07:43:45.5502242Z        * Expected "/api/books/1b45e925-318a-4e8b-a53b-e5fe37a6454d" but got "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6" at $.book.@id
2020-07-11T07:43:45.5502385Z 
2020-07-11T07:43:45.5502610Z   3) Verifying a pact between BookRating and BookStore Given Book Fixtures Loaded A GET request to get books at page 2 with GET /api/books?page=2 returns a response which has a matching body
2020-07-11T07:43:45.5502859Z      Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example
2020-07-11T07:43:45.5502987Z 
2020-07-11T07:43:45.5506015Z        Actual: {"@context":"/api/contexts/Book","@id":"/api/books","@type":"hydra:Collection","hydra:member":[{"@id":"/api/books/064024bd-c301-41c6-8567-6164e3eaba80","@type":"Book","isbn":"9797049777130","title":"Voluptates ut perspiciatis nisi.","description":"Neque in ea beatae corrupti aut iure assumenda minima. Est harum sit eligendi eligendi sequi. Blanditiis et ad in consequatur incidunt voluptatem sint.","author":"Woodrow Collins","publicationDate":"2013-03-10T00:00:00+00:00","reviews":[]},{"@id":"/api/books/1065838a-1ba3-4469-bfa5-96ad7b720df5","@type":"Book","isbn":"9790399460639","title":"Sit quis deleniti consequatur exercitationem.","description":"Minus provident quibusdam fuga aut. Libero quaerat et a nostrum odio veniam reprehenderit.","author":"Mrs. Maurine Marquardt MD","publicationDate":"1983-12-04T00:00:00+00:00","reviews":[]}],"hydra:totalItems":8,"hydra:view":{"@id":"/api/books?page=2","@type":"hydra:PartialCollectionView","hydra:first":"/api/books?page=1","hydra:last":"/api/books?page=4","hydra:previous":"/api/books?page=1","hydra:next":"/api/books?page=3"},"hydra:search":{"@type":"hydra:IriTemplate","hydra:template":"/api/books{?properties[],order[id],order[title],order[author],order[isbn],order[publicationDate],title,author}","hydra:variableRepresentation":"BasicRepresentation","hydra:mapping":[{"@type":"IriTemplateMapping","variable":"properties[]","property":null,"required":false},{"@type":"IriTemplateMapping","variable":"order[id]","property":"id","required":false},{"@type":"IriTemplateMapping","variable":"order[title]","property":"title","required":false},{"@type":"IriTemplateMapping","variable":"order[author]","property":"author","required":false},{"@type":"IriTemplateMapping","variable":"order[isbn]","property":"isbn","required":false},{"@type":"IriTemplateMapping","variable":"order[publicationDate]","property":"publicationDate","required":false},{"@type":"IriTemplateMapping","variable":"title","property":"title","required":false},{"@type":"IriTemplateMapping","variable":"author","property":"author","required":false}]}}
2020-07-11T07:43:45.5506748Z 
2020-07-11T07:43:45.5506910Z        Diff
2020-07-11T07:43:45.5507253Z        --------------------------------------
2020-07-11T07:43:45.5507588Z        Key: �[31m-�[0m�[31m is expected 
2020-07-11T07:43:45.5507922Z        �[0m�[32m     +�[0m�[32m is actual 
2020-07-11T07:43:45.5508337Z        �[0mMatching keys and values are not shown
2020-07-11T07:43:45.5508447Z 
2020-07-11T07:43:45.5508730Z        �[0m {
2020-07-11T07:43:45.5508898Z           "hydra:member": [
2020-07-11T07:43:45.5509063Z             {
2020-07-11T07:43:45.5509370Z        �[31m-      "reviews": [
2020-07-11T07:43:45.5509675Z        �[0m�[31m-        {
2020-07-11T07:43:45.5510128Z        �[0m�[31m-          "@id": "/api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500",
2020-07-11T07:43:45.5510546Z        �[0m�[31m-          "@type": "http://schema.org/Review",
2020-07-11T07:43:45.5511222Z        �[0m�[31m-          "body": "Necessitatibus eius commodi odio ut aliquid. Sit enim molestias in minus aliquid repudiandae qui. Distinctio modi officiis eos suscipit. Vel ut modi quia recusandae qui eligendi. Voluptas totam asperiores ab tenetur voluptatem repudiandae reiciendis."
2020-07-11T07:43:45.5511588Z        �[0m�[31m-        },
2020-07-11T07:43:45.5511909Z        �[0m�[32m+      "reviews": [,
2020-07-11T07:43:45.5512211Z        �[0m�[32m+
2020-07-11T07:43:45.5512500Z        �[0m       ]
2020-07-11T07:43:45.5512665Z             },
2020-07-11T07:43:45.5512824Z             {
2020-07-11T07:43:45.5513129Z        �[31m-      "reviews": [
2020-07-11T07:43:45.5513431Z        �[0m�[31m-        {
2020-07-11T07:43:45.5513828Z        �[0m�[31m-          "@id": "/api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500",
2020-07-11T07:43:45.5514224Z        �[0m�[31m-          "@type": "http://schema.org/Review",
2020-07-11T07:43:45.5514900Z        �[0m�[31m-          "body": "Necessitatibus eius commodi odio ut aliquid. Sit enim molestias in minus aliquid repudiandae qui. Distinctio modi officiis eos suscipit. Vel ut modi quia recusandae qui eligendi. Voluptas totam asperiores ab tenetur voluptatem repudiandae reiciendis."
2020-07-11T07:43:45.5515273Z        �[0m�[31m-        },
2020-07-11T07:43:45.5515593Z        �[0m�[32m+      "reviews": [,
2020-07-11T07:43:45.5515891Z        �[0m�[32m+
2020-07-11T07:43:45.5516184Z        �[0m       ]
2020-07-11T07:43:45.5516345Z             }
2020-07-11T07:43:45.5516505Z           ]
2020-07-11T07:43:45.5516589Z 
2020-07-11T07:43:45.5516755Z        Description of differences
2020-07-11T07:43:45.5517084Z        --------------------------------------
2020-07-11T07:43:45.5517289Z        * Actual array is too short and should have contained a Hash at $.hydra:member[0].reviews[0]
2020-07-11T07:43:45.5517519Z        * Actual array is too short and should have contained a Hash at $.hydra:member[1].reviews[0]
2020-07-11T07:43:45.5517645Z 
2020-07-11T07:43:45.5517863Z   4) Verifying a pact between BookRating and BookStore Given Book Fixtures Loaded A GET request to get books at page 3 with GET /api/books?page=3 returns a response which has a matching body
2020-07-11T07:43:45.5518102Z      Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example
2020-07-11T07:43:45.5518226Z 
2020-07-11T07:43:45.5521368Z        Actual: {"@context":"/api/contexts/Book","@id":"/api/books","@type":"hydra:Collection","hydra:member":[{"@id":"/api/books/3bd2ea9c-e77b-4e5e-9f36-3bd84f1b27b7","@type":"Book","isbn":"9783305357413","title":"Distinctio ut facere et doloremque dolorem et.","description":"Eum saepe ducimus et ipsum neque. Dignissimos ipsam maiores deleniti dicta quod est. Vel enim et quos dolorem et qui. Quibusdam odit laboriosam quia minima quia rerum dicta.","author":"Dena Hegmann","publicationDate":"2014-11-08T00:00:00+00:00","reviews":[]},{"@id":"/api/books/c309917f-4f21-479e-bc6d-6e29e8ad71e7","@type":"Book","isbn":"9798275368604","title":"Molestiae debitis est molestiae enim nisi.","description":"Repudiandae culpa velit consequuntur magni dolores. Id sint nemo ut velit fuga. Voluptas animi non et iure sint sit repellendus vel.","author":"Walton Treutel","publicationDate":"2001-03-11T00:00:00+00:00","reviews":[]}],"hydra:totalItems":8,"hydra:view":{"@id":"/api/books?page=3","@type":"hydra:PartialCollectionView","hydra:first":"/api/books?page=1","hydra:last":"/api/books?page=4","hydra:previous":"/api/books?page=2","hydra:next":"/api/books?page=4"},"hydra:search":{"@type":"hydra:IriTemplate","hydra:template":"/api/books{?properties[],order[id],order[title],order[author],order[isbn],order[publicationDate],title,author}","hydra:variableRepresentation":"BasicRepresentation","hydra:mapping":[{"@type":"IriTemplateMapping","variable":"properties[]","property":null,"required":false},{"@type":"IriTemplateMapping","variable":"order[id]","property":"id","required":false},{"@type":"IriTemplateMapping","variable":"order[title]","property":"title","required":false},{"@type":"IriTemplateMapping","variable":"order[author]","property":"author","required":false},{"@type":"IriTemplateMapping","variable":"order[isbn]","property":"isbn","required":false},{"@type":"IriTemplateMapping","variable":"order[publicationDate]","property":"publicationDate","required":false},{"@type":"IriTemplateMapping","variable":"title","property":"title","required":false},{"@type":"IriTemplateMapping","variable":"author","property":"author","required":false}]}}
2020-07-11T07:43:45.5522048Z 
2020-07-11T07:43:45.5522565Z        Diff
2020-07-11T07:43:45.5522966Z        --------------------------------------
2020-07-11T07:43:45.5523303Z        Key: �[31m-�[0m�[31m is expected 
2020-07-11T07:43:45.5523637Z        �[0m�[32m     +�[0m�[32m is actual 
2020-07-11T07:43:45.5523978Z        �[0mMatching keys and values are not shown
2020-07-11T07:43:45.5524088Z 
2020-07-11T07:43:45.5524374Z        �[0m {
2020-07-11T07:43:45.5524614Z           "hydra:member": [
2020-07-11T07:43:45.5524746Z             {
2020-07-11T07:43:45.5524988Z        �[31m-      "reviews": [
2020-07-11T07:43:45.5525227Z        �[0m�[31m-        {
2020-07-11T07:43:45.5525536Z        �[0m�[31m-          "@id": "/api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500",
2020-07-11T07:43:45.5525855Z        �[0m�[31m-          "@type": "http://schema.org/Review",
2020-07-11T07:43:45.5526381Z        �[0m�[31m-          "body": "Necessitatibus eius commodi odio ut aliquid. Sit enim molestias in minus aliquid repudiandae qui. Distinctio modi officiis eos suscipit. Vel ut modi quia recusandae qui eligendi. Voluptas totam asperiores ab tenetur voluptatem repudiandae reiciendis."
2020-07-11T07:43:45.5526677Z        �[0m�[31m-        },
2020-07-11T07:43:45.5526929Z        �[0m�[32m+      "reviews": [,
2020-07-11T07:43:45.5527159Z        �[0m�[32m+
2020-07-11T07:43:45.5527389Z        �[0m       ]
2020-07-11T07:43:45.5527519Z             },
2020-07-11T07:43:45.5527645Z             {
2020-07-11T07:43:45.5527885Z        �[31m-      "reviews": [
2020-07-11T07:43:45.5528120Z        �[0m�[31m-        {
2020-07-11T07:43:45.5528426Z        �[0m�[31m-          "@id": "/api/reviews/fb5a885f-f7e8-4a50-950f-c1a64a94d500",
2020-07-11T07:43:45.5528729Z        �[0m�[31m-          "@type": "http://schema.org/Review",
2020-07-11T07:43:45.5529239Z        �[0m�[31m-          "body": "Necessitatibus eius commodi odio ut aliquid. Sit enim molestias in minus aliquid repudiandae qui. Distinctio modi officiis eos suscipit. Vel ut modi quia recusandae qui eligendi. Voluptas totam asperiores ab tenetur voluptatem repudiandae reiciendis."
2020-07-11T07:43:45.5529525Z        �[0m�[31m-        },
2020-07-11T07:43:45.5529774Z        �[0m�[32m+      "reviews": [,
2020-07-11T07:43:45.5530003Z        �[0m�[32m+
2020-07-11T07:43:45.5530228Z        �[0m       ]
2020-07-11T07:43:45.5530355Z             }
2020-07-11T07:43:45.5530485Z           ]
2020-07-11T07:43:45.5530567Z 
2020-07-11T07:43:45.5530699Z        Description of differences
2020-07-11T07:43:45.5530957Z        --------------------------------------
2020-07-11T07:43:45.5531118Z        * Actual array is too short and should have contained a Hash at $.hydra:member[0].reviews[0]
2020-07-11T07:43:45.5531289Z        * Actual array is too short and should have contained a Hash at $.hydra:member[1].reviews[0]
2020-07-11T07:43:45.5531374Z 
2020-07-11T07:43:45.5531502Z 5 interactions, 4 failures
2020-07-11T07:43:45.5531585Z 
2020-07-11T07:43:45.5531709Z Failed interactions:
2020-07-11T07:43:45.5531872Z 
2020-07-11T07:43:45.5532012Z * A get request to get books at page 1 given Book Fixtures Loaded
2020-07-11T07:43:45.5532164Z * A get request to get review given Book Fixtures Loaded
2020-07-11T07:43:45.5532319Z * A get request to get books at page 2 given Book Fixtures Loaded
2020-07-11T07:43:45.5532471Z * A get request to get books at page 3 given Book Fixtures Loaded
2020-07-11T07:43:45.5533303Z INFO: Verification results published to ***/pacts/provider/BookStore/consumer/BookRating/pact-version/64b4fb942fd101dc013a22e87b2824dc97625df5/verification-results/161
2020-07-11T07:43:45.5533417Z 
2020-07-11T07:43:45.5533543Z  [] []
2020-07-11T07:43:45.5533999Z [2020-07-11T07:43:45.545059+00:00] console.ERROR: err > WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']@['id']
2020-07-11T07:43:45.5534644Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]@['id']
2020-07-11T07:43:45.5535166Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/reviews\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]['reviews'][*]@['id']
2020-07-11T07:43:45.5535664Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['book']@['id']
2020-07-11T07:43:45.5536138Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/reviews\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']@['id']
2020-07-11T07:43:45.5536629Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]@['id']
2020-07-11T07:43:45.5537138Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/reviews\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]['reviews'][*]@['id']
2020-07-11T07:43:45.5537632Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]@['id']
2020-07-11T07:43:45.5538151Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/reviews\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]['reviews'][*]@['id']
2020-07-11T07:43:45.5538658Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]@['id']
2020-07-11T07:43:45.5539171Z WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"^\\/api\\/reviews\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"} for path $['body']['hydra:member'][*]['reviews'][*]@['id']
2020-07-11T07:43:45.5539356Z  [] []
2020-07-11T07:43:45.5540350Z run [-o|--override OVERRIDE] [-e|--ext EXT] [--report] [--html [HTML]] [--xml [XML]] [--phpunit-xml [PHPUNIT-XML]] [--tap [TAP]] [--json [JSON]] [--colors] [--no-colors] [--silent] [--steps] [-d|--debug] [--bootstrap [BOOTSTRAP]] [--no-redirect] [--coverage [COVERAGE]] [--coverage-html [COVERAGE-HTML]] [--coverage-xml [COVERAGE-XML]] [--coverage-text [COVERAGE-TEXT]] [--coverage-crap4j [COVERAGE-CRAP4J]] [--coverage-phpunit [COVERAGE-PHPUNIT]] [--no-exit] [-g|--group GROUP] [-s|--skip SKIP] [-x|--skip-group SKIP-GROUP] [--env ENV] [-f|--fail-fast] [--no-rebuild] [--seed SEED] [--no-artifacts] [--] [<suite> [<test>]]
2020-07-11T07:43:45.5540573Z 
2020-07-11T07:43:46.4127867Z ##[error]Process completed with exit code 1.

  • Pact
Pact (simplified)

{
  "consumer": {
    "name": "BookPublisher"
  },
  "provider": {
    "name": "BookStore"
  },
  "interactions": [
    {
      "description": "A POST request to create book",
      "providerState": "Book Fixtures Loaded",
      "request": {
        "method": "POST",
        "path": "/api/books",
        "headers": {
          "Content-Type": "application/json"
        },
        "body": {
          "isbn": "0099740915",
          "title": "The Handmaid's Tale",
          "description": "Brilliantly conceived and executed, this powerful evocation of twenty-first century America gives full rein to Margaret Atwood's devastating irony, wit and astute perception.",
          "author": "Margaret Atwood",
          "publicationDate": "1985-07-31T00:00:00+00:00"
        },
        "matchingRules": {
          "$.body.isbn": {
            "match": "type"
          },
          "$.body.title": {
            "match": "type"
          },
          "$.body.description": {
            "match": "type"
          },
          "$.body.author": {
            "match": "type"
          },
          "$.body.publicationDate": {
            "match": "type"
          }
        }
      },
      "response": {
        "status": 201,
        "headers": {
          "Content-Type": "application/ld+json; charset=utf-8"
        },
        "body": {
          "@context": "/api/contexts/Book",
          "@id": "/api/books/0114b2a8-3347-49d8-ad99-0e792c5a30e6",
          "@type": "Book",
          "title": "Voluptas et tempora repellat corporis excepturi.",
          "description": "Quaerat odit quia nisi accusantium natus voluptatem. Explicabo corporis eligendi ut ut sapiente ut qui quidem. Optio amet velit aut delectus. Sed alias asperiores perspiciatis deserunt omnis. Mollitia unde id in.",
          "author": "Melisa Kassulke",
          "publicationDate": "1999-02-13T00:00:00+07:00",
          "reviews": [

          ]
        },
        "matchingRules": {
          "$.body.@id": {
            "match": "regex",
            "regex": "^\\/api\\/books\\/[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$"
          },
          "$.body.title": {
            "match": "type"
          },
          "$.body.description": {
            "match": "type"
          },
          "$.body.author": {
            "match": "type"
          },
          "$.body.publicationDate": {
            "match": "regex",
            "regex": "^\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)$"
          }
        }
      }
    }
  ],
  "metadata": {
    "pactSpecification": {
      "version": "2.0.0"
    }
  }
}

@mefellows
Copy link
Member

Thanks so much for raising a detailed report, this is great! Llat first glance it looks like something we need to investigate.

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

No branches or pull requests

2 participants