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

Root level array causes TypeError #60

Closed
philsturgeon opened this issue Oct 2, 2017 · 1 comment
Closed

Root level array causes TypeError #60

philsturgeon opened this issue Oct 2, 2017 · 1 comment

Comments

@philsturgeon
Copy link

Hey there! I've hit a bit of an issue, and at this time I'm not sure how to fix it. I'll dig in soon, but on the off-chance you're aware of the problem (or anyone else notices things) here it is.

  1) Invalidations::IndexController GET /invalidations has a valid contract
     Failure/Error: expect(result).to match_response_schema('invalidations')

     TypeError:
       wrong element type Hash at 0 (expected array)
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/payload.rb:19:in `to_h'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/payload.rb:19:in `extract_json_string'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/payload.rb:4:in `initialize'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/validator.rb:8:in `new'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/validator.rb:8:in `initialize'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/matcher.rb:38:in `new'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/matcher.rb:38:in `build_validator'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/matcher.rb:12:in `matches?'
     # /usr/local/bundle/gems/json_matchers-0.7.1/lib/json_matchers/rspec.rb:72:in `block (2 levels) in <top (required)>'
     # ./spec/requests/invalidations/index_spec.rb:19:in `block (3 levels) in <top (required)>'

Standard test:

    it 'has a valid contract' do
      result = JSON.parse(response.body)['result']
      expect(result).to match_response_schema('invalidations')
    end

That invalidations file:

{
  "type": "array",
  "items": {
    "$ref": "invalidation.json"
  }
}

Is this due to the top level object being an array instead of a hash?

seanpdoyle added a commit that referenced this issue Oct 3, 2017
Closes [#60]

Add support for an Array matcher argument similar to [Hash matcher
arguments][#59].

[#59]: #59
[#60]: #60
@seanpdoyle
Copy link
Collaborator

Could you pull down #61 and try it out?

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