Class: HashMap::Matchers::HashMappedMatcher
- Inherits:
-
Object
- Object
- HashMap::Matchers::HashMappedMatcher
- Defined in:
- lib/hash_map/matchers.rb
Instance Attribute Summary collapse
-
#description_messages ⇒ Object
readonly
Returns the value of attribute description_messages.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#expected_provided ⇒ Object
readonly
Returns the value of attribute expected_provided.
-
#failure_messages ⇒ Object
readonly
Returns the value of attribute failure_messages.
-
#from_key ⇒ Object
readonly
Returns the value of attribute from_key.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#mapped_has_key ⇒ Object
readonly
Returns the value of attribute mapped_has_key.
-
#mapped_hash ⇒ Object
readonly
Returns the value of attribute mapped_hash.
-
#original_hash ⇒ Object
readonly
Returns the value of attribute original_hash.
Instance Method Summary collapse
- #and_eq(expected) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #from(original_hash, *from_key) ⇒ Object
-
#initialize(key) ⇒ HashMappedMatcher
constructor
A new instance of HashMappedMatcher.
- #matches?(hash) ⇒ Boolean
Constructor Details
#initialize(key) ⇒ HashMappedMatcher
Returns a new instance of HashMappedMatcher.
11 12 13 14 15 16 |
# File 'lib/hash_map/matchers.rb', line 11 def initialize(key) @key = key @error = [] @description_messages = [] @failure_messages = [] end |
Instance Attribute Details
#description_messages ⇒ Object (readonly)
Returns the value of attribute description_messages.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def @description_messages end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def expected @expected end |
#expected_provided ⇒ Object (readonly)
Returns the value of attribute expected_provided.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def expected_provided @expected_provided end |
#failure_messages ⇒ Object (readonly)
Returns the value of attribute failure_messages.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def @failure_messages end |
#from_key ⇒ Object (readonly)
Returns the value of attribute from_key.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def from_key @from_key end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def key @key end |
#mapped_has_key ⇒ Object (readonly)
Returns the value of attribute mapped_has_key.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def mapped_has_key @mapped_has_key end |
#mapped_hash ⇒ Object (readonly)
Returns the value of attribute mapped_hash.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def mapped_hash @mapped_hash end |
#original_hash ⇒ Object (readonly)
Returns the value of attribute original_hash.
8 9 10 |
# File 'lib/hash_map/matchers.rb', line 8 def original_hash @original_hash end |
Instance Method Details
#and_eq(expected) ⇒ Object
37 38 39 40 41 |
# File 'lib/hash_map/matchers.rb', line 37 def and_eq(expected) @expected_provided = true @expected = expected self end |
#description ⇒ Object
23 24 25 |
# File 'lib/hash_map/matchers.rb', line 23 def description .join(', ') end |
#failure_message ⇒ Object
27 28 29 |
# File 'lib/hash_map/matchers.rb', line 27 def .join(', ') end |
#failure_message_when_negated ⇒ Object
43 44 45 |
# File 'lib/hash_map/matchers.rb', line 43 def "expect to not #{description}" end |
#from(original_hash, *from_key) ⇒ Object
31 32 33 34 35 |
# File 'lib/hash_map/matchers.rb', line 31 def from(original_hash, *from_key) @original_hash = original_hash @from_key = from_key self end |
#matches?(hash) ⇒ Boolean
18 19 20 21 |
# File 'lib/hash_map/matchers.rb', line 18 def matches?(hash) @mapped_hash = hash _has_key && _from && equality end |