Skip to content

Commit

Permalink
Add step to assert a field is not present (#1760)
Browse files Browse the repository at this point in the history
* Add step to assert a field is not present

* Fix method naming

---------

Co-authored-by: skarimo <[email protected]>
  • Loading branch information
antonio-ramadas-dd and skarimo authored Mar 11, 2024
1 parent 586daa5 commit c85ac3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .generator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ def expect_response_has_field(context, response_path, field):
"""Check that a response has field."""


@then(parsers.parse('the response "{response_path}" does not have field "{field}"'))
def expect_response_does_not_have_field(context, response_path, field):
"""Check that a response path does not have field."""


@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
def expect_array_contains_object(context, response_path, key_path, value):
"""Check that a response attribute contains an object with the specified key and value."""
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ def model_builder(param, obj)
expect(@response[0].lookup response_path).to include(field.to_sym)
end

Then(/the response "([^"]+)" does not have field "([^"]+)"/) do |response_path, field|
expect(@response[0].lookup response_path).to_not include(field.to_sym)
end

Then(/^the response "([^"]+)" has the same value as "(.*)"$/) do |response_path, fixture_path|
expect(@response[0].lookup response_path).to eq fixtures.lookup(fixture_path)
end
Expand Down

0 comments on commit c85ac3c

Please sign in to comment.