Sha256: 9537a19d31bffbd90a8786e2ea4c153286e7d8c941155eb88b91e60d67050856
Contents?: true
Size: 784 Bytes
Versions: 1
Compression:
Stored size: 784 Bytes
Contents
module WildcardMatchers module Matchers # RSpeck::Mocks has hash_including define_wildcard_matcher(:hash_includes) class HashIncludes < ::WildcardMatchers::WildcardMatcher protected def wildcard_match(actual) unless actual.is_a?(Hash) errors.push "#{position}: expect #{actual} to Hash" end hash_to_match = {} hash_to_match = expectation.pop if expectation.last.is_a?(Hash) expectation.each do |key| errors << "#{position}: expect #{actual} to have key #{key}" unless actual.has_key?(key) end hash_to_match.each do |key, value| errors.push(*self.class.superclass.check_errors(actual[key], value, position + "[#{key.inspect}]")) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wildcard_matchers-0.1.2 | lib/wildcard_matchers/matchers/hash_includes.rb |