Class: ActiveModelSerializers::Test::Schema::AssertSchema
- Inherits:
-
Object
- Object
- ActiveModelSerializers::Test::Schema::AssertSchema
- Defined in:
- lib/active_model_serializers/test/schema.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#schema_path ⇒ Object
readonly
Returns the value of attribute schema_path.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(schema_path, request, response, message, payload = nil) ⇒ AssertSchema
constructor
Interface may change.
Constructor Details
#initialize(schema_path, request, response, message, payload = nil) ⇒ AssertSchema
Interface may change.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/active_model_serializers/test/schema.rb', line 42 def initialize(schema_path, request, response, , payload = nil) require_json_schema! @request = request @response = response @payload = payload @schema_path = schema_path || schema_path_default @message = @document_store = JsonSchema::DocumentStore.new add_schema_to_document_store end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
39 40 41 |
# File 'lib/active_model_serializers/test/schema.rb', line 39 def @message end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
39 40 41 |
# File 'lib/active_model_serializers/test/schema.rb', line 39 def payload @payload end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
39 40 41 |
# File 'lib/active_model_serializers/test/schema.rb', line 39 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
39 40 41 |
# File 'lib/active_model_serializers/test/schema.rb', line 39 def response @response end |
#schema_path ⇒ Object (readonly)
Returns the value of attribute schema_path.
39 40 41 |
# File 'lib/active_model_serializers/test/schema.rb', line 39 def schema_path @schema_path end |
Instance Method Details
#call ⇒ Object
53 54 55 56 57 58 |
# File 'lib/active_model_serializers/test/schema.rb', line 53 def call json_schema.(store: document_store) status, errors = json_schema.validate(response_body) @message = [, errors.map(&:to_s).to_sentence].compact.join(': ') status end |