30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/kind/__lib__/assert_hash.rb', line 30
def any(hash, spec)
spec.each do |key, expected|
value = hash[key]
error_message = "The key #{key.inspect} has an invalid value"
case expected
when KindAny, KindObject, KindUnionType then assert_kind_object(expected, value, error_message)
when ::Module then assert_kind_of(expected, value, error_message)
when ::Proc then assert(expected.call(value), error_message)
when ::Regexp then assert_match(expected, value, error_message)
when ::NilClass then assert_nil(value, error_message)
else assert_equal(expected, value, error_message)
end
end
hash
end
|