Class: RSpec::JsonMatchers::Matchers::BeJsonMatcher Private
- Inherits:
-
Object
- Object
- RSpec::JsonMatchers::Matchers::BeJsonMatcher
- Defined in:
- lib/rspec/json_matchers/matchers/be_json_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.
The implementation for #be_json
Direct Known Subclasses
Instance Attribute Summary collapse
- #actual ⇒ Object readonly private
Instance Method Summary collapse
-
#description ⇒ String
private
Expectation description in spec result summary.
- #does_not_match?(*args) ⇒ Boolean private
-
#failure_message ⇒ String
private
Failure message displayed when a positive example failed (e.g. using
should). -
#failure_message_when_negated ⇒ String
private
Failure message displayed when a negative example failed (e.g. using
should_not). - #matches?(json) ⇒ Boolean private
-
#with_content(expected) ⇒ BeJsonWithContentMatcher
Get a matcher that try to match the content of actual with nested various expectations.
Instance Attribute Details
#actual ⇒ Object (readonly)
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.
21 22 23 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 21 def actual @actual end |
Instance Method Details
#description ⇒ String
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.
Expectation description in spec result summary
51 52 53 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 51 def description "be a valid JSON string" 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.
31 32 33 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 31 def does_not_match?(*args) !matches?(*args) end |
#failure_message ⇒ String
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.
Failure message displayed when a positive example failed (e.g. using should)
59 60 61 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 59 def "expected value to be parsed as JSON, but failed" end |
#failure_message_when_negated ⇒ String
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.
Failure message displayed when a negative example failed (e.g. using should_not)
67 68 69 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 67 def "expected value not to be parsed as JSON, but succeeded" end |
#matches?(json) ⇒ 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.
23 24 25 26 27 28 29 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 23 def matches?(json) @actual = JSON.parse(json) true rescue JSON::ParserError @has_parser_error = true false end |
#with_content(expected) ⇒ BeJsonWithContentMatcher
Get a matcher that try to match the content of actual with nested various expectations
44 45 46 |
# File 'lib/rspec/json_matchers/matchers/be_json_matcher.rb', line 44 def with_content(expected) BeJsonWithContentMatcher.new(expected) end |