Class: OpenapiRspec::RequestValidator
- Inherits:
-
Object
- Object
- OpenapiRspec::RequestValidator
- Extended by:
- Dry::Initializer
- Includes:
- Rack::Test::Methods
- Defined in:
- lib/openapi_rspec/request_validator.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
21 22 23 |
# File 'lib/openapi_rspec/request_validator.rb', line 21 def response @response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
21 22 23 |
# File 'lib/openapi_rspec/request_validator.rb', line 21 def result @result end |
Instance Method Details
#app ⇒ Object
23 24 25 |
# File 'lib/openapi_rspec/request_validator.rb', line 23 def app OpenapiRspec.app end |
#description ⇒ Object
36 37 38 |
# File 'lib/openapi_rspec/request_validator.rb', line 36 def description "return valid response with code #{code} on `#{method.to_s.upcase} #{path}`" end |
#failure_message ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/openapi_rspec/request_validator.rb', line 40 def if response (%W[Response: #{response.body}] + result.errors).join("\n") else result.errors.join("\n") end end |
#matches?(doc) ⇒ Boolean
27 28 29 30 31 32 33 34 |
# File 'lib/openapi_rspec/request_validator.rb', line 27 def matches?(doc) @result = doc.validate_request(path: path, method: method, code: code, media_type: media_type) return false unless result.valid? perform_request(doc) result.validate_response(body: response.body, code: response.status) result.valid? end |