collectiveidea / json_spec

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

Request: "in yaml" option, so you can write features in YAML but compare it to JSON #46

Closed rangerscience closed 11 years ago

rangerscience commented 11 years ago

JSON is for computers; YAML is for people; so are features!

I rigged this:

Then /^the JSON response should be \(in yaml\):$/  do |yaml|
  step 'the JSON response should be:', YAML.parse(yaml).to_json
end

so I could:

Then the JSON response should be (in yaml):
"""
  chunky:
  - bacon
"""

but just for that one step. It'd be nice if I could do that to any of them, without having to write a translation step, and as part of json_spec itself. (I am testing a JSON api, but I still don't want to write JSON if I can help it)

laserlemon commented 11 years ago

Sorry but I won't be adding this. The library is for communicating and asserting JSON. Adding another layer of deserialization/serialization introduces an unnecessary level of complexity as well as a performance hit.