collectiveidea / json_spec

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

"Expected Included JSON" RSpec Exception doesn't have any more info #45

Closed rangerscience closed 7 years ago

rangerscience commented 11 years ago
$ step 'the JSON response should include:', JSON.pretty_generate(data)
*** RSpec::Expectations::ExpectationNotMetError Exception: Expected included JSON

Whereas:

$ step 'the JSON response should be:', JSON.pretty_generate(data)
*** RSpec::Expectations::ExpectationNotMetError Exception: Expected equivalent JSON
Diff:
@@ -2,19 +2,7 @@
(diff)

Ruby 2 / Rails 4 / JSON Spec 1.1.1

laserlemon commented 11 years ago

Comfortable with a pull request?

rangerscience commented 11 years ago

Maybe? Do you mean, "make my own fork and accept a pull request from you"?

laserlemon commented 11 years ago

I mean please feel free to fork the repo, make the change (with tests) and submit a pull request.

rangerscience commented 11 years ago

I could make a go of it.

rangerscience commented 11 years ago

The lazy fix is pretty simple - just enable diffing for the include matcher, but it breaks a lot of tests and it's the same diff you'd get with be. Dunno yet if that's the best.

https://github.com/narfanator/json_spec/commit/1e36fc67d2df5f1dcb6aef57040bbfe793331c5b

rangerscience commented 11 years ago

...course, the tests fail because it breaks things that way. Fixed; just provide what's needed for the diff (diffable, expected, actual), but don't override any of the existing functionality. I think the full diff works - rather than just showing what's expected and missing - since it provides context. I'll chuck you a pull request, and if you want some more in the way of testing/functionality, let me know?

marshallshen commented 11 years ago

I submitted PR related to this issue, but closed it since it wasn't reviewed.. https://github.com/collectiveidea/json_spec/pull/42

Thoughts?

shekibobo commented 7 years ago

Closed via #53