Class: JsonSpec::Matchers::HaveJsonPath
- Inherits:
-
Object
- Object
- JsonSpec::Matchers::HaveJsonPath
show all
- Includes:
- Helpers
- Defined in:
- lib/json_spec/matchers.rb
Instance Method Summary
collapse
Methods included from Helpers
#generate_normalized_json, #normalize_json, #parse_json
Constructor Details
Returns a new instance of HaveJsonPath.
119
120
121
|
# File 'lib/json_spec/matchers.rb', line 119
def initialize(path)
@path = path
end
|
Instance Method Details
#description ⇒ Object
140
141
142
|
# File 'lib/json_spec/matchers.rb', line 140
def description
%(have JSON path "#{@path}")
end
|
#failure_message_for_should ⇒ Object
132
133
134
|
# File 'lib/json_spec/matchers.rb', line 132
def failure_message_for_should
%(Expected JSON path "#{@path}")
end
|
#failure_message_for_should_not ⇒ Object
136
137
138
|
# File 'lib/json_spec/matchers.rb', line 136
def failure_message_for_should_not
%(Expected no JSON path "#{@path}")
end
|
#matches?(json) ⇒ Boolean
123
124
125
126
127
128
129
130
|
# File 'lib/json_spec/matchers.rb', line 123
def matches?(json)
begin
parse_json(json, @path)
true
rescue JsonSpec::MissingPathError
false
end
end
|