Class: WebMock::Matchers::HashIncludingMatcher
- Inherits:
-
Object
- Object
- WebMock::Matchers::HashIncludingMatcher
- Defined in:
- lib/webmock/matchers/hash_including_matcher.rb
Overview
this is a based on RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/argument_matchers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(actual) ⇒ Object
-
#initialize(expected) ⇒ HashIncludingMatcher
constructor
A new instance of HashIncludingMatcher.
- #inspect ⇒ Object
Constructor Details
#initialize(expected) ⇒ HashIncludingMatcher
Returns a new instance of HashIncludingMatcher.
6 7 8 |
# File 'lib/webmock/matchers/hash_including_matcher.rb', line 6 def initialize(expected) @expected = Hash[WebMock::Util::HashKeysStringifier.stringify_keys!(expected, :deep => true).sort] end |
Class Method Details
.from_rspec_matcher(matcher) ⇒ Object
20 21 22 |
# File 'lib/webmock/matchers/hash_including_matcher.rb', line 20 def self.from_rspec_matcher(matcher) new(matcher.instance_variable_get(:@expected)) end |
Instance Method Details
#==(actual) ⇒ Object
10 11 12 13 14 |
# File 'lib/webmock/matchers/hash_including_matcher.rb', line 10 def ==(actual) @expected.all? {|k,v| actual.has_key?(k) && v === actual[k]} rescue NoMethodError false end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/webmock/matchers/hash_including_matcher.rb', line 16 def inspect "hash_including(#{@expected.inspect})" end |