-
Notifications
You must be signed in to change notification settings - Fork 114
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
New matcher that asserts presence of the given fields #35
base: master
Are you sure you want to change the base?
Conversation
@@ -25,6 +26,10 @@ def have_json_type(type) | |||
def have_json_size(size) | |||
JsonSpec::Matchers::HaveJsonSize.new(size) | |||
end | |||
|
|||
def have_json_fields(size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fields
rather than size
, right?
Please reference #25 to see what I'd like to see in order to pull this in. Thank you! |
@laserlemon check out latest commit |
@laserlemon are there any other problems with this pr? :) |
@charlierudolph nice catch, fixed |
@AlexanderPavlenko Thanks for all of your work! There are just a couple things I would change and I'll comment on those individually in the diff. Thank you again! |
|
||
Scenario: Base paths | ||
When I get the JSON | ||
Then the JSON should have keys "a, b, c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since "a, b, c"
is a valid JSON key, we should separate each key out into its own quotes:
Then the JSON should have keys "a", "b", "c"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -70,6 +70,16 @@ | |||
end | |||
end | |||
|
|||
Then /^the (?:JSON|json)(?: response)?(?: at "(.*)")? should( not)? have the following keys:$/ do |base, negative, table| | |||
match = have_json_keys(table.raw) | |||
match = match.at_path(base) if base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename base
to path
to be consistent.
Can then shorten to one line as its works if path is nil.
match = have_json_keys(table.raw).at_path(path)
Nice drying up. Will make use of this pattern to dry up the rest of cucumber later.
No description provided.