Comments (5)
Yes, the ?
and *
are for checking against elements in an array. Your api is returning a hash. What are you trying to test for?
from airborne.
I am trying to check that all the nodes returned contain :position, instead of just 0. How do I do that?
from airborne.
Offhand, you can loop through the keys on json_body
and call expect_json_keys
for each.
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.
from airborne.
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 airborne
but will work as well. The main issue is that you're treating an object like that of an array. If we see more use cases for this in the future, we can add support to airborne
for this.
from airborne.
Alex,
Thank you. That’s hacky, but it does in fact do what I need it to do. Thanks for much for pointing out how to do that.
-Frances
On Jan 9, 2015, at 7:56 AM, Alex Friedman [email protected] wrote:
@json_body = json_body.values expect_json_keys('?', [:position])
from airborne.
Related Issues (20)
- GET from test environment HOT 1
- How to set verify_ssl => false HOT 4
- Faraday Response support HOT 1
- Potential incompatibility with RSpec 3.5.4 HOT 7
- Routing error with post action
- Ruby 2.4 warnings HOT 2
- Is there a way to test for the absence of data? HOT 9
- ARRAY: Api request returned invalid json (Airborne::InvalidJsonError) HOT 6
- Argument error when making POST requests HOT 2
- Looking for Project Maintainers HOT 13
- : (
- Bug: expect_json_sizes with * don't work as expected
- JSON array body instead of hash body in POST/PUT
- Why header keys are downcased? HOT 1
- Is it possible to use on a non-request spec?
- is it possible to use 'Content_Type' => 'application/xml'
- Rails 5.1.5 compatibilty HOT 1
- Is this project dead? HOT 17
- PUT request with no request_body and error messaging issue HOT 1
- Not working with rails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airborne.