Class: Matchers::JSON::DocumentContainsJSONPath
- Inherits:
-
Object
- Object
- Matchers::JSON::DocumentContainsJSONPath
- Includes:
- JSONPath
- Defined in:
- lib/matchers/json/document_contains_json_path.rb
Instance Method Summary collapse
-
#initialize(json_path) ⇒ DocumentContainsJSONPath
constructor
A new instance of DocumentContainsJSONPath.
-
#matches?(document_s) ⇒ Boolean
Exceptions caught by JSON Parser will be thrown up the stack ::JSON::ParserError in the case of invalid JSON.
Methods included from JSONPath
#json_path_valid?, #value_on_path
Constructor Details
#initialize(json_path) ⇒ DocumentContainsJSONPath
Returns a new instance of DocumentContainsJSONPath.
6 7 8 |
# File 'lib/matchers/json/document_contains_json_path.rb', line 6 def initialize(json_path) @json_path = json_path end |
Instance Method Details
#matches?(document_s) ⇒ Boolean
Exceptions caught by JSON Parser will be thrown up the stack ::JSON::ParserError in the case of invalid JSON
13 14 15 16 |
# File 'lib/matchers/json/document_contains_json_path.rb', line 13 def matches?(document_s) json_hash = ::JSON.parse(document_s) !value_on_path(json_hash, @json_path).nil? end |