Class: RSpec::JsonMatcher::AbstractComparer
- Inherits:
-
Object
- Object
- RSpec::JsonMatcher::AbstractComparer
- Defined in:
- lib/rspec/json_matcher/abstract_comparer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Class Method Summary collapse
Instance Method Summary collapse
- #compare ⇒ Object
-
#initialize(actual, expected, &reason) ⇒ AbstractComparer
constructor
A new instance of AbstractComparer.
Constructor Details
#initialize(actual, expected, &reason) ⇒ AbstractComparer
Returns a new instance of AbstractComparer.
18 19 20 21 22 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 18 def initialize(actual, expected, &reason) @actual = actual @expected = expected @reason = reason end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
4 5 6 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 4 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
4 5 6 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 4 def expected @expected end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
4 5 6 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 4 def reason @reason end |
Class Method Details
.compare(*args, &reason) ⇒ Object
6 7 8 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 6 def self.compare(*args, &reason) new(*args, &reason).compare end |
.extract_keys(array_or_hash) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 10 def self.extract_keys(array_or_hash) if array_or_hash.is_a?(Array) array_or_hash.each_index.to_a else array_or_hash.keys.map(&:to_s) end end |
Instance Method Details
#compare ⇒ Object
24 25 26 |
# File 'lib/rspec/json_matcher/abstract_comparer.rb', line 24 def compare has_same_value? || has_same_collection? end |