Module: RSpecApi::Expectations::Response::Body
- Included in:
- RSpecApi::Expectations::Response
- Defined in:
- lib/rspec-api/expectations/body.rb,
lib/rspec-api/expectations/body/sort.rb,
lib/rspec-api/expectations/body/jsonp.rb,
lib/rspec-api/expectations/body/filter.rb,
lib/rspec-api/expectations/body/attributes.rb,
lib/rspec-api/expectations/body/collection.rb
Overview
Creates an example group for expectations on the response body of the last API request and runs it to verify that it matches best practices:
-
if response is succesful and has a body
-
the body should be a JSON-marshalled Array or Hash
-
if request has a callback parameter, the body should be JSONP
-
if request has a sort parameter, the body should be sorted
-
if request has a filter parameter, the body should be filtered
-
if some attributes are expected, the body should include them
-
Defined Under Namespace
Modules: Attributes, Collection, Filter, Jsonp, Sort
Instance Method Summary collapse
Instance Method Details
#expect_body(response, expectations = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rspec-api/expectations/body.rb', line 19 def expect_body(response, expectations = {}) context 'responds with a body that' do extend Collection extend Jsonp extend Sort extend Filter extend Attributes expect_a_collection response, expectations expect_a_callback_wrapped response, expectations expect_a_sorted response, expectations expect_a_filtered response, expectations expect_attributes response, expectations end if expectations.any? end |