-
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
Is there a way to test for the absence of data? #126
Comments
You can adjust the strictness with |
You can read more about it here https://github.com/brooklynDev/airborne#configuration |
Hey @sethpollack - thanks for the response :) I did initially go that route, but the payload in question is considerably more complex than the example I provided. It would make it quite tedious to test an entire huge payload just to ensure that one key is not there. If it's OK with you, I'd like to issue a PR to expand the API's Sound good? |
You can also test that it is there and expect it to fail |
I'm a little slow on the uptake today :) How would I go about doing that? |
|
Ah. Of course. Thanks for that. I'd still like to issue that PR nonetheless if you're still keen? |
What did you have in mind? |
So, something like the following: { "foo": "bar" }
Similarly:
The examples are tending towards the contrived, but I feel they add a lot more expressiveness than nesting an expectation and checking for an exception. It would also hew closer to how RSpec does things by providing a complementary It would work great for other matchers like |
Hi guys,
I was just wondering if there is a way to test for the absence of JSON using airborne? My particular use case centers around me testing whether or not I am successfully sideloading some data using a toggle param, of which it has a default to not sideload under certain conditions.
Example: No sideloading
Example: sideloading
For my tests, I wish to test that in the no sideloading example, the "extraStuff" key is not there. Is this possible?
I naïvely thought
!expect_json_types(extraStuff: :object)
would work, but it unfortunately doesn't.Any help or pointers would be greatly appreciated. Right now, I'm pulling the json out of
json_body
, and doing anexpect(blob).to_not have_key :extraStuff
, which works, but is... not super pretty.The text was updated successfully, but these errors were encountered: