Class: OpenapiContracts::Match
- Inherits:
-
Object
- Object
- OpenapiContracts::Match
- Defined in:
- lib/openapi_contracts/match.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ parameters: false, request_body: false }.freeze
- MIN_REQUEST_ANCESTORS =
%w(Rack::Request::Env Rack::Request::Helpers).freeze
- MIN_RESPONSE_ANCESTORS =
%w(Rack::Response::Helpers).freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(doc, response, options = {}) ⇒ Match
constructor
A new instance of Match.
- #valid? ⇒ Boolean
Constructor Details
#initialize(doc, response, options = {}) ⇒ Match
Returns a new instance of Match.
12 13 14 15 16 17 18 19 |
# File 'lib/openapi_contracts/match.rb', line 12 def initialize(doc, response, = {}) @doc = doc @response = response @request = .delete(:request) { response.request } @options = DEFAULT_OPTIONS.merge() raise ArgumentError, "#{@response} must be compatible with Rack::Response::Helpers" unless response_compatible? raise ArgumentError, "#{@request} must be compatible with Rack::Request::{Env,Helpers}" unless request_compatible? end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
10 11 12 |
# File 'lib/openapi_contracts/match.rb', line 10 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/openapi_contracts/match.rb', line 21 def valid? return @errors.empty? if instance_variable_defined?(:@errors) @errors = matchers.call @doc.coverage.increment!(operation.path.to_s, request_method, status, media_type) if collect_coverage? @errors.empty? end |