-
Notifications
You must be signed in to change notification settings - Fork 30
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
ContainSubtree
constraint
#6
Conversation
Sorry, I missed this PR. Would you be willing to rebase on the |
Hi, sure, as soon as I learn how to do that :) |
I did a rebase althouth I'm not sure it worked. Can you look at it? I also commited the nuspec, please ignore it when merging. |
Apparently you forgot to change the target branch to release 5.0. I didn't see that and accidentally merged this change. I'm currently merging 5.0 to master, so I'll ping you to re-apply the change later on |
This constraint will match a JSON document against a subtree. This is useful when verifying JSON data, and multiple but not all properties of an object must be compared against known values.
Example: I am testing some CRUD web service, have a response like this:
...and I want to assert that the request succeeded and the returned object has type
my-type
with nameFoo
. The other properties are irrelevant and/or unknown. Without this assertion, I'd have to write something like this:Yuck! The same test can be done with a single call using
ContainSubtree
:When using with arrays, the assertion is that the JSON array under testing must contain a matching element for each of the elements in the subtree array, eg. this should fail: