Class: Matchers::JSON::JSONPathHasValue
- Inherits:
-
Object
- Object
- Matchers::JSON::JSONPathHasValue
- Includes:
- JSONPath
- Defined in:
- lib/matchers/json/json_path_has_value.rb
Instance Method Summary collapse
-
#initialize(json_path, json_value) ⇒ JSONPathHasValue
constructor
A new instance of JSONPathHasValue.
- #matches?(document_s) ⇒ Boolean
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
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 |