Class: Matchers::JSON::JSONPathHasObject
- Inherits:
-
Object
- Object
- Matchers::JSON::JSONPathHasObject
- Includes:
- JSONPath
- Defined in:
- lib/matchers/json/json_path_has_object.rb
Instance Method Summary collapse
-
#initialize(json_path, json_object) ⇒ JSONPathHasObject
constructor
A new instance of JSONPathHasObject.
- #matches?(document_s) ⇒ Boolean
Methods included from JSONPath
#json_path_valid?, #value_on_path
Constructor Details
#initialize(json_path, json_object) ⇒ JSONPathHasObject
Returns a new instance of JSONPathHasObject.
6 7 8 9 |
# File 'lib/matchers/json/json_path_has_object.rb', line 6 def initialize(json_path, json_object) @json_path = json_path @json_object = json_object.is_a?(Hash) ? json_object : ::JSON.parse(json_object) end |
Instance Method Details
#matches?(document_s) ⇒ Boolean
11 12 13 14 |
# File 'lib/matchers/json/json_path_has_object.rb', line 11 def matches?(document_s) json_hash = ::JSON.parse(document_s) value_on_path(json_hash, @json_path) == @json_object end |