# features/step_definitions/ember_data_compliance_steps.rb

Then /^the response body should fulfill the Ember Data expectations for (\w+)( list)?$/ do |model, multiple|
  json = JSON.parse(last_response.body)
  # The JSON response should be wrapped with it's model name,
  # see http://emberjs.com/guides/models/the-rest-adapter/#toc_json-root
  # Example:
  #    {
  #       "product": {
  #         "id": 1,
  #         "name": "carrots"
  #       }
  #    }
  #
  JSONSelect(".#{multiple ? model.underscore.pluralize : model.underscore}").test(json).should be_true
end