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

Improve error message when array is longer than expected #31

Closed
bethesque opened this issue Apr 6, 2017 · 3 comments
Closed

Improve error message when array is longer than expected #31

bethesque opened this issue Apr 6, 2017 · 3 comments

Comments

@bethesque
Copy link
Member

See http://stackoverflow.com/questions/42948214/pact-verify-provider-what-does-pactunexpectedindex-mean/42988501

@R-M-F-at-C-A
Copy link

I would find the following clearer:

        "data": {
            "attributes": {
              "stuff": [
+                 {
+                    "foo": "bar",
+                    ... 
+                   "baz": "quok",
+                  }   
              ]
            }
          }

The description is pretty good though:

       Description of differences
       --------------------------------------
       * Actual array is too long and should not contain a Hash at $.data.attributes.stuff[0]

@bethesque
Copy link
Member Author

Agreed, I like your suggested output.

The diff output will be replaced by whatever is in the shared rust implementation once that is integrated into the ruby codebase.

@YOU54F
Copy link
Member

YOU54F commented Aug 15, 2024

Believe this is resolved as per comments in #49 (comment)

The output now looks like

  1) Verifying a pact between Foo and Bar A retrieve thing request with GET /thing returns a response which has a matching body
     Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example
     
       Actual: {"company":"My Company","factories":[{"location":"Sydney","capacity":5},{"location":"Sydney","geographicCoords":"-0.145,1.4445","capacity":5}]}
     
       Diff
       --------------------------------------
       Key: - is expected 
            + is actual 
       Matching keys and values are not shown
       
        {
          "factories": [
            ... ,
       +    {
       +      "location": "Sydney",
       +      "geographicCoords": "-0.145,1.4445",
       +      "capacity": 5
       +    },
          ]
        }
       
       Description of differences
       --------------------------------------
       * Actual array is too long and should not contain a Hash at $.factories[1]

removing the confusing Pact:UnexpectedIndex and showing the additional contents which were not expected.

Checking the output of the same test using the pact_ffi library, which would be introduced by pact-foundation/pact-ruby#317

Failures:

1) Verifying a pact between V4-consumer and V4-provider - a retrieve thing request
    1.1) has a matching body
           $.factories -> Expected a List with 1 elements but received 2 elements

There were 1 pact failures

@YOU54F YOU54F closed this as completed Aug 15, 2024
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

3 participants