class OpenapiFirst::Coverage

Attributes

to_be_called[R]

Public Class Methods

new(app, spec) click to toggle source
# File lib/openapi_first/coverage.rb, line 7
def initialize(app, spec)
  @app = app
  @spec = spec
  @to_be_called = spec.operations.map do |operation|
    endpoint_id(operation)
  end
end

Public Instance Methods

call(env) click to toggle source
# File lib/openapi_first/coverage.rb, line 15
def call(env)
  response = @app.call(env)
  operation = env[OPERATION]
  @to_be_called.delete(endpoint_id(operation)) if operation
  response
end

Private Instance Methods

endpoint_id(operation) click to toggle source
# File lib/openapi_first/coverage.rb, line 24
def endpoint_id(operation)
  "#{operation.path}##{operation.method}"
end