collectiveidea / json_spec

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

be_json_eql(:null) is not intuitive #23

Closed crimsonknave closed 12 years ago

crimsonknave commented 12 years ago

It seems very counter intuitive to me that to check if the json is null I need to pass the string null and can't pass the nil object. I'm pretty sure I was able to do this in previous versions. I'd love to see either an example in the readme if that is the desired behavior.

laserlemon commented 12 years ago

The purpose of the JSON matchers is to compare JSON to other JSON. If you want to assert the Ruby value at a path, you can use the json_spec helpers like so:

parse_json(your_json, your_path).should == your_ruby

Does that help?

crimsonknave commented 12 years ago

Ok, that makes sense. I'll just update my tests to be like: it { should be_json_eql(object.to_json) }