collectiveidea / json_spec

Easily handle JSON in RSpec and Cucumber
rubygems.org/gems/json_spec
MIT License
919 stars 114 forks source link

JSON null value is counted as 1 entry #81

Closed eluns closed 10 years ago

eluns commented 10 years ago

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

I created a fork and then did a pull request https://github.com/collectiveidea/json_spec/pull/80

laserlemon commented 10 years ago

Closed for reasons described in #80. Thank you!