Class: RSpec::JsonMatchers::Matchers::BeJsonWithContentMatcher Abstract Private
- Inherits:
-
BeJsonMatcher
- Object
- BeJsonMatcher
- RSpec::JsonMatchers::Matchers::BeJsonWithContentMatcher
- Defined in:
- lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Parent of matcher classes that requires #at_path & #with_exact_keys This is not merged with BeJsonMatcher since it should be able to be used alone
Instance Method Summary collapse
-
#actual ⇒ Object
private
Override RSpec::JsonMatchers::Matchers::BeJsonMatcher#actual It return actual object extracted by #path And also detect & set state for path error (either it’s invalid or fails to extract).
-
#at_path(path) ⇒ BeJsonWithSomethingMatcher
private
Sets the path to be used for object, to avoid passing a deep nested Hash or Array as expectation Defaults to “” (if this is not called).
- #does_not_match?(*args) ⇒ Boolean private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#initialize(expected) ⇒ BeJsonWithContentMatcher
constructor
private
A new instance of BeJsonWithContentMatcher.
- #matches?(*_args) ⇒ Boolean private
Methods inherited from BeJsonMatcher
Constructor Details
#initialize(expected) ⇒ BeJsonWithContentMatcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BeJsonWithContentMatcher.
21 22 23 24 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 21 def initialize(expected) @expected = expected @path = JsonMatchers::Utils::KeyPath::Path.new("") end |
Instance Method Details
#actual ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override RSpec::JsonMatchers::Matchers::BeJsonMatcher#actual It return actual object extracted by #path And also detect & set state for path error (either it’s invalid or fails to extract)
42 43 44 45 46 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 42 def actual result = path.extract(super) has_path_error! if result.failed? result.object end |
#at_path(path) ⇒ BeJsonWithSomethingMatcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the path to be used for object, to avoid passing a deep nested Hash or Array as expectation Defaults to “” (if this is not called)
The path uses period (“.”) as separator for parts Also period cannot be used as path name as a side-effect
This does NOT raise error if the path is invalid (like having 2 periods, 1 period at the start/end of string) But it will fail the example with both ‘should` & `should_not`
65 66 67 68 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 65 def at_path(path) @path = JsonMatchers::Utils::KeyPath::Path.new(path) self end |
#does_not_match?(*args) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 30 def does_not_match?(*args) !matches?(*args) && has_valid_path? end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Overrides RSpec::JsonMatchers::Matchers::BeJsonMatcher#failure_message
71 72 73 74 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 71 def return super if has_parser_error? (true) end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Overrides RSpec::JsonMatchers::Matchers::BeJsonMatcher#failure_message_when_negated
77 78 79 80 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 77 def return super if has_parser_error? (false) end |
#matches?(*_args) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/rspec/json_matchers/matchers/be_json_with_content_matcher.rb', line 26 def matches?(*_args) super && has_valid_path? && expected_and_actual_matched? end |