Sha256: 2b6a1c2cb89ecc78b756239e20790fcb5846626b48a02c728ab89a0cc92cbed5
Contents?: true
Size: 819 Bytes
Versions: 4
Compression:
Stored size: 819 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 && actual.is_a?(Hash) errors.push "#{position}: expect #{actual.inspect} to Hash" return 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
4 entries across 4 versions & 1 rubygems