mirror of
https://github.com/ditkrg/rails-template.git
synced 2026-01-22 13:56:42 +00:00
25 lines
679 B
Ruby
25 lines
679 B
Ruby
module Rspec
|
|
module Helpers
|
|
def jsonapi_wrapper_for_factories_configurations
|
|
file 'spec/helpers/swagger_errors.rb', <<~CODE
|
|
module Helpers
|
|
module JsonapiWrapperForFactories
|
|
def wrap_factory_with_jsonapi(factory)
|
|
attributes = factory.instance_of?(Hash) ? factory : factory.attributes
|
|
{
|
|
data: {
|
|
id: factory.try(:id) || '',
|
|
attributes: attributes.deep_transform_keys { |key| key&.to_s&.camelize :lower }
|
|
},
|
|
jsonapi: {
|
|
version: '1.0'
|
|
}
|
|
}
|
|
end
|
|
end
|
|
end
|
|
CODE
|
|
end
|
|
end
|
|
end
|