Class: Matchers::JSON::JSONPathHasValue

Inherits:
Object
  • Object
show all
Includes:
JSONPath
Defined in:
lib/matchers/json/json_path_has_value.rb

Instance Method Summary collapse

Methods included from JSONPath

#json_path_valid?, #value_on_path

Constructor Details

#initialize(json_path, json_value) ⇒ JSONPathHasValue

Returns a new instance of JSONPathHasValue.



6
7
8
9
# File 'lib/matchers/json/json_path_has_value.rb', line 6

def initialize(json_path, json_value)
  @json_path = json_path
  @json_value = json_value
end

Instance Method Details

#matches?(document_s) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/matchers/json/json_path_has_value.rb', line 11

def matches?(document_s)
  json_hash = ::JSON.parse(document_s)
  value_on_path(json_hash, @json_path) == @json_value
end