Class: JsonMatchers::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/json_matchers/matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema_path) ⇒ Matcher

Returns a new instance of Matcher.



7
8
9
10
# File 'lib/json_matchers/matcher.rb', line 7

def initialize(schema_path)
  @schema_path = schema_path
  @document_store = build_and_populate_document_store
end

Instance Method Details

#matches?(payload) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/json_matchers/matcher.rb', line 12

def matches?(payload)
  self.errors = validator.validate(payload)

  errors.empty?
end

#validation_failure_messageObject



18
19
20
# File 'lib/json_matchers/matcher.rb', line 18

def validation_failure_message
  errors.first.to_s
end