Module: RSpec::Rails::Api::DSL::Example
- Defined in:
- lib/rspec/rails/api/dsl/example.rb
Overview
These methods will be available in examples (i.e.: ‘for_code’)
Instance Method Summary collapse
-
#test_response_of(example, path_params: {}, payload: {}, headers: {}, ignore_content_type: false, ignore_response: false) ⇒ void
Visits the current example and tests the response.
Instance Method Details
#test_response_of(example, path_params: {}, payload: {}, headers: {}, ignore_content_type: false, ignore_response: false) ⇒ void
This method returns an undefined value.
Visits the current example and tests the response
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rspec/rails/api/dsl/example.rb', line 19 def test_response_of(example, path_params: {}, payload: {}, headers: {}, ignore_content_type: false, ignore_response: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/ParameterLists, Layout/LineLength raise 'Missing context. Call "test_response_of" within a "for_code" block.' unless example status_code = prepare_status_code example.class.description request_params = prepare_request_params example.class.module_parent.description, path_params, payload, headers send(request_params[:action], request_params[:url], params: request_params[:params], headers: request_params[:headers]) check_response(response, status_code, ignore_content_type: ignore_content_type) unless ignore_response return if example.class.description.match?(/-> test (\d+)(.*)/) set_request_example example.class.[:rra], request_params, status_code, response.body end |