Class: JsonMatchers::Matcher
- Inherits:
-
Object
- Object
- JsonMatchers::Matcher
- Defined in:
- lib/json_matchers/matcher.rb
Instance Method Summary collapse
-
#initialize(schema_path, **options) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(response) ⇒ Boolean
- #validation_failure_message ⇒ Object
Constructor Details
#initialize(schema_path, **options) ⇒ Matcher
Returns a new instance of Matcher.
5 6 7 8 |
# File 'lib/json_matchers/matcher.rb', line 5 def initialize(schema_path, **) @schema_path = schema_path @options = end |
Instance Method Details
#matches?(response) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/json_matchers/matcher.rb', line 10 def matches?(response) @response = response = { strict: true, }.merge() JSON::Validator.validate!( schema_path.to_s, response.body, , ) rescue JSON::Schema::ValidationError => ex @validation_failure_message = ex. false rescue JSON::ParserError raise InvalidSchemaError end |
#validation_failure_message ⇒ Object
29 30 31 |
# File 'lib/json_matchers/matcher.rb', line 29 def @validation_failure_message.to_s end |