Module: Matchers::JSON::JSONPathHasThing

Included in:
JSONPathHasArray, JSONPathHasObject
Defined in:
lib/matchers/json/json_path_has_thing.rb

Instance Method Summary collapse

Instance Method Details

#initialize(json_path, json_thing) ⇒ Object



5
6
7
8
# File 'lib/matchers/json/json_path_has_thing.rb', line 5

def initialize(json_path, json_thing)
  @json_path = json_path
  @json_thing = discriminate json_thing
end

#matches?(document_s) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/matchers/json/json_path_has_thing.rb', line 10

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