-
Notifications
You must be signed in to change notification settings - Fork 124
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
Expected ? to be array got Hash from JSON response #33
Comments
Yes, the |
I am trying to check that all the nodes returned contain :position, instead of just 0. How do I do that? |
Offhand, you can loop through the keys on Something like this: json_body.keys.each do |el|
expect_json_keys(el.to_s, [:position])
end @fmorales I just updated the example the last one had a bug in it. |
An alternative approach to what @sethpollack posted, is to use a little bit of hackery: @json_body = json_body.values
expect_json_keys('?', [:position]) This relies on some implementation details of |
Alex,
|
When I hit this uri
http://voteapi-cloud-test.telescope.tv/moderation/getMessages?topic_id=1000336
and use this expectation
expect_json_keys('?', [:position])
I get this error:
Failure/Error: expect_json_keys('?', [:position])
Expected ? to be array got Hash from JSON response
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/path_matcher.rb:99:in `ensure_array'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/path_matcher.rb:11:in`block in get_by_path'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/path_matcher.rb:9:in `each'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/path_matcher.rb:9:in`each_with_index'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/path_matcher.rb:9:in `get_by_path'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/request_expectations.rb:87:in`call_with_path'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/request_expectations.rb:23:in `expect_json_keys'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/request_expectations.rb:62:in`call'
/Users/francesmorales/.rvm/gems/ruby-2.1.2/gems/airborne-0.1.10/lib/airborne/request_expectations.rb:62:in `block (2 levels) in module:RequestExpectations'
./spec/sandbox/toys_rspec.rb:22:in`block (2 levels) in <top (required)>'
I get the same error for *
Am I still running into a bug, or am I doing something wrong?
The text was updated successfully, but these errors were encountered: