module ActiveModelSerializers::Test::Schema

Constants

InvalidSchemaError
MissingSchema

Public Instance Methods

assert_request_response_schema(schema_path = nil, message = nil) click to toggle source

May be renamed

# File lib/active_model_serializers/test/schema.rb, line 25
def assert_request_response_schema(schema_path = nil, message = nil)
  assert_request_schema(schema_path, message)
  assert_response_schema(schema_path, message)
end
assert_request_schema(schema_path = nil, message = nil) click to toggle source
# File lib/active_model_serializers/test/schema.rb, line 19
def assert_request_schema(schema_path = nil, message = nil)
  matcher = AssertRequestSchema.new(schema_path, request, response, message)
  assert(matcher.call, matcher.message)
end
assert_response_schema(schema_path = nil, message = nil) click to toggle source

A Minitest Assertion that test the response is valid against a schema. @param schema_path [String] a custom schema path @param message [String] a custom error message @return [Boolean] true when the response is valid @return [Minitest::Assertion] when the response is invalid @example

get :index
assert_response_schema
# File lib/active_model_serializers/test/schema.rb, line 14
def assert_response_schema(schema_path = nil, message = nil)
  matcher = AssertResponseSchema.new(schema_path, request, response, message)
  assert(matcher.call, matcher.message)
end
assert_schema(payload, schema_path = nil, message = nil) click to toggle source
# File lib/active_model_serializers/test/schema.rb, line 30
def assert_schema(payload, schema_path = nil, message = nil)
  matcher = AssertSchema.new(schema_path, request, response, message, payload)
  assert(matcher.call, matcher.message)
end