Class: JsonMatchers::Assertion
- Inherits:
-
Object
- Object
- JsonMatchers::Assertion
- Defined in:
- lib/json_matchers/assertion.rb
Instance Method Summary collapse
-
#initialize(schema_name) ⇒ Assertion
constructor
A new instance of Assertion.
- #invalid_failure_message ⇒ Object
- #valid?(json) ⇒ Boolean
- #valid_failure_message ⇒ Object
Constructor Details
#initialize(schema_name) ⇒ Assertion
Returns a new instance of Assertion.
8 9 10 11 12 |
# File 'lib/json_matchers/assertion.rb', line 8 def initialize(schema_name) @schema_name = schema_name.to_s @schema_path = JsonMatchers.path_to_schema(schema_name) @matcher = Matcher.new(schema_path) end |
Instance Method Details
#invalid_failure_message ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/json_matchers/assertion.rb', line 36 def <<-FAIL #{} --- expected #{format_json(payload)} not to match schema "#{schema_name}": #{format_json(schema_body)} FAIL end |
#valid?(json) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/json_matchers/assertion.rb', line 14 def valid?(json) @payload = Payload.new(json) matcher.matches?(payload) end |
#valid_failure_message ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/json_matchers/assertion.rb', line 20 def <<-FAIL #{} --- expected #{format_json(payload)} to match schema "#{schema_name}": #{format_json(schema_body)} FAIL end |