Class: Adapter::JsonApi
- Inherits:
-
Object
- Object
- Adapter::JsonApi
- Includes:
- RSpec::Matchers
- Defined in:
- lib/rspec/api_helpers/adapter/jsonapi/adapter.rb
Class Method Summary collapse
Class Method Details
.collection(options, response, _binding) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/rspec/api_helpers/adapter/jsonapi/adapter.rb', line 14 def collection(, response, _binding) jsonapi_collection = HashWithIndifferentAccess.new(JSON.parse(response.body)) jsonapi_collection = transform_collection(jsonapi_collection.dig('data') || {}) return Adapter::ActiveModel::Collection.new(, jsonapi_collection, _binding) end |
.resource(options, response, _binding) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/rspec/api_helpers/adapter/jsonapi/adapter.rb', line 6 def resource(, response, _binding) jsonapi_resource = HashWithIndifferentAccess.new(JSON.parse(response.body)) jsonapi_resource = transform_resource(jsonapi_resource.dig('data') || {}) return Adapter::ActiveModel::Resource.new(, jsonapi_resource, _binding) end |