collectiveidea/json_spec — pull request #80 by eluns (2014-09-30 23:01:31+00:00)
Title: return size of 0 if json ruby value is nil

An entry can be null such as [null], which is 1 entry. If a null is a value of an Array, then the array has 0 entry. However a null value returns a size of 1

def matches?(json)
ruby = parse_json(json, @path)
#when ruby = nil
#NoMethodError: undefined method `size' for nil:NilClass
# so @actual = 1 when ruby is nil
# seems false return 0 rather then 1?
@actual = Enumerable === ruby ? ruby.size : 1
@actual == @expected
end