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
27
28
29
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 27
def description
%(have JSON path "#{@path}")
end
|
#failure_message ⇒ Object
Also known as:
failure_message_for_should
17
18
19
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 17
def failure_message
%(Expected JSON path "#{@path}")
end
|
#failure_message_when_negated ⇒ Object
Also known as:
failure_message_for_should_not
22
23
24
|
# File 'lib/json_spec/matchers/have_json_path.rb', line 22
def failure_message_when_negated
%(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
|