Class: JsonSpec::Matchers::HaveJsonPath
- Inherits:
-
Object
- Object
- JsonSpec::Matchers::HaveJsonPath
show all
- Includes:
- Helpers
- Defined in:
- lib/json_spec/matchers/have_json_path.rb
Instance Method Summary
collapse
Methods included from Helpers
#generate_normalized_json, #load_json, #normalize_json, #parse_json
Constructor Details
Returns a new instance of HaveJsonPath.
6
7
8
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 6
def initialize(path)
@path = path
end
|
Instance Method Details
#description ⇒ Object
25
26
27
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 25
def description
%(have JSON path "#{@path}")
end
|
#failure_message_for_should ⇒ Object
17
18
19
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 17
def failure_message_for_should
%(Expected JSON path "#{@path}")
end
|
#failure_message_for_should_not ⇒ Object
21
22
23
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 21
def failure_message_for_should_not
%(Expected no JSON path "#{@path}")
end
|
#matches?(json) ⇒ Boolean
10
11
12
13
14
15
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 10
def matches?(json)
parse_json(json, @path)
true
rescue JsonSpec::MissingPath
false
end
|