Class: JsonRspecMatchMaker::Base
- Inherits:
-
Object
- Object
- JsonRspecMatchMaker::Base
- Defined in:
- lib/json_rspec_match_maker/base.rb
Overview
Base class that abstracts away all of the work of using the @match_definition
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
private
The object being expected against.
-
#match_definition ⇒ Hash
readonly
private
Data structure that specifies how instance values relate to JSON values.
-
#target ⇒ Hash
readonly
private
The json being tested.
Instance Method Summary collapse
-
#failure_message ⇒ String
Error reporting method called by RSpec.
-
#initialize(expected) ⇒ Base
constructor
Create a new JSON matcher.
-
#matches?(target) ⇒ Bool
Match method called by RSpec.
Constructor Details
#initialize(expected) ⇒ Base
Create a new JSON matcher
35 36 37 38 |
# File 'lib/json_rspec_match_maker/base.rb', line 35 def initialize(expected) @expected = expected @errors = {} end |
Instance Attribute Details
#expected ⇒ 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.
The object being expected against
17 18 19 |
# File 'lib/json_rspec_match_maker/base.rb', line 17 def expected @expected end |
#match_definition ⇒ Hash (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.
Data structure that specifies how instance values relate to JSON values
27 28 29 |
# File 'lib/json_rspec_match_maker/base.rb', line 27 def match_definition @match_definition end |
#target ⇒ Hash (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.
The json being tested
22 23 24 |
# File 'lib/json_rspec_match_maker/base.rb', line 22 def target @target end |
Instance Method Details
#failure_message ⇒ String
Error reporting method called by RSpec
57 58 59 |
# File 'lib/json_rspec_match_maker/base.rb', line 57 def @errors.values.join('\n') end |
#matches?(target) ⇒ Bool
Match method called by RSpec
46 47 48 49 50 |
# File 'lib/json_rspec_match_maker/base.rb', line 46 def matches?(target) @target = target check_target_against_expected @errors.empty? end |