Class: OpenapiFirst::Test::App
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- OpenapiFirst::Test::App
- Defined in:
- lib/openapi_first/test/app.rb
Overview
A wrapper of the original app with silent request/response validation to track requests/responses.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, api:) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(app, api:) ⇒ App
Returns a new instance of App.
13 14 15 16 17 |
# File 'lib/openapi_first/test/app.rb', line 13 def initialize(app, api:) super(app) @app = app @definition = Test[api] end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/openapi_first/test/app.rb', line 19 def call(env) request = Rack::Request.new(env) env[Test::REQUEST] = @definition.validate_request(request, raise_error: false) response = @app.call(env) status, headers, body = response env[Test::RESPONSE] = @definition.validate_response(request, Rack::Response[status, headers, body], raise_error: false) response end |