Class: ActiveModelSerializers::Test::Schema::AssertResponseSchema
- Inherits:
-
Object
- Object
- ActiveModelSerializers::Test::Schema::AssertResponseSchema
- Defined in:
- lib/active_model_serializers/test/schema.rb
Instance Attribute Summary (collapse)
-
- (Object) message
readonly
Returns the value of attribute message.
-
- (Object) response
readonly
Returns the value of attribute response.
-
- (Object) schema_path
readonly
Returns the value of attribute schema_path.
Instance Method Summary (collapse)
- - (Object) call
-
- (AssertResponseSchema) initialize(schema_path, response, message)
constructor
A new instance of AssertResponseSchema.
Constructor Details
- (AssertResponseSchema) initialize(schema_path, response, message)
Returns a new instance of AssertResponseSchema
23 24 25 26 27 28 29 30 |
# File 'lib/active_model_serializers/test/schema.rb', line 23 def initialize(schema_path, response, ) require_json_schema! @response = response @schema_path = schema_path || schema_path_default @message = @document_store = JsonSchema::DocumentStore.new add_schema_to_document_store end |
Instance Attribute Details
- (Object) message (readonly)
Returns the value of attribute message
21 22 23 |
# File 'lib/active_model_serializers/test/schema.rb', line 21 def @message end |
- (Object) response (readonly)
Returns the value of attribute response
21 22 23 |
# File 'lib/active_model_serializers/test/schema.rb', line 21 def response @response end |
- (Object) schema_path (readonly)
Returns the value of attribute schema_path
21 22 23 |
# File 'lib/active_model_serializers/test/schema.rb', line 21 def schema_path @schema_path end |
Instance Method Details
- (Object) call
32 33 34 35 36 37 |
# File 'lib/active_model_serializers/test/schema.rb', line 32 def call json_schema.(store: document_store) status, errors = json_schema.validate(response_body) @message ||= errors.map(&:to_s).to_sentence status end |