36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/web/assertinclude.rb', line 36
def do_thing haystack, k, v, fullname, fullname_str
message = ""
if !haystack.has_key?(k)
if v
message += "Missing from actual: #{fullname_str} => #{v.inspect}\n"
end
else
if v.kind_of?(Hash) || v.kind_of?(Array)
if !(haystack.__index(k).kind_of?(String) || haystack.__index(k).kind_of?(TrueClass) || haystack.__index(k).kind_of?(FalseClass) || haystack.__index(k).kind_of?(Fixnum) || haystack.__index(k).kind_of?(Bignum))
message += v.compare_includes?(haystack.__index(k),fullname)
else
message += "Difference: required <#{fullname_str} => #{v.inspect}> was <#{fullname_str} => #{haystack.__index(k).inspect}>\n"
end
else
haystack_value = haystack.__index(k)
if (haystack_value.kind_of? Array and
haystack_value.length == 1)
haystack_value = haystack_value.first
end
if (haystack_value != v)
message += "Difference: required <#{fullname_str} => #{v.inspect}> was <#{fullname_str} => #{haystack_value.inspect}>\n"
end
end
end
message
end
|