mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
It is a common pattern to use JSON Schema to validate a API response[1], [2] and [3]. This patch creates the `assert_response_schema` test helper that helps people do this kind of validation easily on the controller tests. [1]: https://robots.thoughtbot.com/validating-json-schemas-with-an-rspec-matcher [2]: https://github.com/sharethrough/json-schema-rspec [3]: https://github.com/rails-api/active_model_serializers/issues/1011#issuecomment-127608121
29 lines
791 B
Ruby
29 lines
791 B
Ruby
module ActiveModel
|
|
class Serializer
|
|
module Configuration
|
|
include ActiveSupport::Configurable
|
|
extend ActiveSupport::Concern
|
|
|
|
# Configuration options may also be set in
|
|
# Serializers and Adapters
|
|
included do |base|
|
|
config = base.config
|
|
config.collection_serializer = ActiveModel::Serializer::CollectionSerializer
|
|
config.serializer_lookup_enabled = true
|
|
|
|
def config.array_serializer=(collection_serializer)
|
|
self.collection_serializer = collection_serializer
|
|
end
|
|
|
|
def config.array_serializer
|
|
collection_serializer
|
|
end
|
|
|
|
config.adapter = :attributes
|
|
config.jsonapi_resource_type = :plural
|
|
config.schema_path = 'test/support/schemas'
|
|
end
|
|
end
|
|
end
|
|
end
|