Class: Suhyo::HashMatchers::IncludeHash
- Inherits:
-
Object
- Object
- Suhyo::HashMatchers::IncludeHash
- Defined in:
- lib/suhyo/hash_matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(hash) ⇒ IncludeHash
constructor
A new instance of IncludeHash.
- #matches?(target) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(hash) ⇒ IncludeHash
Returns a new instance of IncludeHash.
3 4 5 |
# File 'lib/suhyo/hash_matchers.rb', line 3 def initialize(hash) @hash = hash end |
Instance Method Details
#failure_message ⇒ Object
15 16 17 |
# File 'lib/suhyo/hash_matchers.rb', line 15 def "Expected hash to include #{@hash.inspect} but got #{@target.inspect}" end |
#matches?(target) ⇒ Boolean
7 8 9 10 11 12 13 |
# File 'lib/suhyo/hash_matchers.rb', line 7 def matches?(target) @target = target @hash.each do |key, value| return false unless target[key] == value end true end |
#negative_failure_message ⇒ Object
19 20 21 |
# File 'lib/suhyo/hash_matchers.rb', line 19 def "Expected hash not to include #{@hash.inspect} but got #{@target.inspect}" end |