Class: Skooma::Matchers::ConformResponseSchema
- Inherits:
-
ConformRequestSchema
- Object
- ConformRequestSchema
- Skooma::Matchers::ConformResponseSchema
- Defined in:
- lib/skooma/matchers/conform_response_schema.rb
Direct Known Subclasses
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(skooma, mapped_response, expected) ⇒ ConformResponseSchema
constructor
A new instance of ConformResponseSchema.
- #matches? ⇒ Boolean
Constructor Details
#initialize(skooma, mapped_response, expected) ⇒ ConformResponseSchema
Returns a new instance of ConformResponseSchema.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/skooma/matchers/conform_response_schema.rb', line 8 def initialize(skooma, mapped_response, expected) super(skooma, mapped_response) @expected = expected case expected when Symbol @expected_code = Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(expected) when Integer @expected_code = expected else raise ArgumentError, "Expected symbol or number, got expected=#{expected.inspect}" end end |
Instance Method Details
#description ⇒ Object
23 24 25 |
# File 'lib/skooma/matchers/conform_response_schema.rb', line 23 def description "conform response schema with #{@expected} response code" end |
#failure_message ⇒ Object
33 34 35 36 37 |
# File 'lib/skooma/matchers/conform_response_schema.rb', line 33 def return "Expected #{@expected} status code, but got #{@mapped_response["response"]["status"]}" unless status_matches? super end |
#matches? ⇒ Boolean
27 28 29 30 31 |
# File 'lib/skooma/matchers/conform_response_schema.rb', line 27 def matches?(*) return false unless status_matches? super end |