Class: RSpec::ComposableJSONMatchers::BeJSON Private
- Inherits:
-
Object
- Object
- RSpec::ComposableJSONMatchers::BeJSON
- Includes:
- Matchers::Composable
- Defined in:
- lib/rspec/composable_json_matchers/be_json.rb
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.
Instance Attribute Summary collapse
- #configuration ⇒ Object readonly private
- #decoded_actual ⇒ Object (also: #actual) readonly private
- #matcher ⇒ Object readonly private
- #original_actual ⇒ Object readonly private
- #parser_error ⇒ Object readonly private
Instance Method Summary collapse
- #description ⇒ Object private
- #diffable? ⇒ Boolean private
- #does_not_match?(actual) ⇒ Boolean private
- #expected ⇒ Object private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
-
#initialize(matcher, configuration) ⇒ BeJSON
constructor
private
A new instance of BeJSON.
- #matches?(actual) ⇒ Boolean private
Constructor Details
#initialize(matcher, configuration) ⇒ BeJSON
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 BeJSON.
11 12 13 14 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 11 def initialize(matcher, configuration) @matcher = matcher @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ 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.
9 10 11 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 9 def configuration @configuration end |
#decoded_actual ⇒ Object (readonly) Also known as: actual
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.
9 10 11 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 9 def decoded_actual @decoded_actual end |
#matcher ⇒ 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.
9 10 11 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 9 def matcher @matcher end |
#original_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.
9 10 11 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 9 def original_actual @original_actual end |
#parser_error ⇒ 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.
9 10 11 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 9 def parser_error @parser_error end |
Instance Method Details
#description ⇒ 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.
30 31 32 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 30 def description "be JSON #{matcher.description}" end |
#diffable? ⇒ 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.
44 45 46 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 44 def diffable? parser_error.nil? && matcher.diffable? end |
#does_not_match?(actual) ⇒ 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.
25 26 27 28 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 25 def does_not_match?(actual) matched = matches?(actual) parser_error ? false : !matched end |
#expected ⇒ 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.
48 49 50 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 48 def expected matcher.expected 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.
34 35 36 37 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 34 def return if "expected #{original_actual} to be JSON #{matcher.description}" 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.
39 40 41 42 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 39 def return if "expected #{original_actual} not to be JSON #{matcher.description}" end |
#matches?(actual) ⇒ 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.
16 17 18 19 20 21 22 23 |
# File 'lib/rspec/composable_json_matchers/be_json.rb', line 16 def matches?(actual) @original_actual = actual @decoded_actual = parse(original_actual) matcher.matches?(decoded_actual) rescue JSON::ParserError => error @parser_error = error false end |