Class: OpenapiContracts::Matchers::MatchOpenapiDoc
- Inherits:
-
Object
- Object
- OpenapiContracts::Matchers::MatchOpenapiDoc
- Defined in:
- lib/openapi_contracts/matchers/match_openapi_doc.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(doc, options) ⇒ MatchOpenapiDoc
constructor
A new instance of MatchOpenapiDoc.
- #matches?(response) ⇒ Boolean
- #with_http_status(status) ⇒ Object
Constructor Details
#initialize(doc, options) ⇒ MatchOpenapiDoc
Returns a new instance of MatchOpenapiDoc.
4 5 6 7 8 |
# File 'lib/openapi_contracts/matchers/match_openapi_doc.rb', line 4 def initialize(doc, ) @doc = doc @options = @errors = [] end |
Instance Method Details
#description ⇒ Object
25 26 27 28 29 |
# File 'lib/openapi_contracts/matchers/match_openapi_doc.rb', line 25 def description desc = 'to match the openapi schema' desc << " with #{http_status_desc(@status)}" if @status desc end |
#failure_message ⇒ Object
31 32 33 |
# File 'lib/openapi_contracts/matchers/match_openapi_doc.rb', line 31 def @errors.map { |e| "* #{e}" }.join("\n") end |
#failure_message_when_negated ⇒ Object
35 36 37 |
# File 'lib/openapi_contracts/matchers/match_openapi_doc.rb', line 35 def 'request matched the schema' end |
#matches?(response) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/openapi_contracts/matchers/match_openapi_doc.rb', line 19 def matches?(response) @response = response response_documented? && http_status_matches? && [headers_match?, body_matches?].all? @errors.empty? end |
#with_http_status(status) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/openapi_contracts/matchers/match_openapi_doc.rb', line 10 def with_http_status(status) if status.is_a? Symbol @status = Rack::Utils::SYMBOL_TO_STATUS_CODE[status] else @status = status end self end |