lib/wildcard_matchers.rb in wildcard_matchers-0.0.1 vs lib/wildcard_matchers.rb in wildcard_matchers-0.0.2

- old
+ new

@@ -30,10 +30,12 @@ end end # TODO: class ArrayMatcher ? def check_array(actual, expected, position, &on_failure) + return false unless actual.is_a?(Array) + if expected.size == actual.size actual.zip(expected).map.with_index do |(a, e), index| recursive_match(a, e, position + "[#{index}]", &on_failure) end.all? else @@ -46,9 +48,11 @@ end end # TODO: class HashMatcher ? def check_hash(actual, expected, position, &on_failure) + return false unless actual.is_a?(Hash) + if (actual.keys - expected.keys).size == 0 && (expected.keys - actual.keys).size == 0 expected.map do |key, value| recursive_match(actual[key], value, position + "[#{key.inspect}]", &on_failure) end.all? else