Module: OpenapiFirst::Test::Coverage
- Defined in:
- lib/openapi_first/test/coverage.rb,
lib/openapi_first/test/coverage/plan.rb,
lib/openapi_first/test/coverage/tracker.rb,
lib/openapi_first/test/coverage/route_task.rb,
lib/openapi_first/test/coverage/request_task.rb,
lib/openapi_first/test/coverage/html_reporter.rb,
lib/openapi_first/test/coverage/response_task.rb,
lib/openapi_first/test/coverage/covered_request.rb,
lib/openapi_first/test/coverage/covered_response.rb,
lib/openapi_first/test/coverage/terminal_reporter.rb,
lib/openapi_first/test/coverage/html_reporter/context.rb
Overview
The Coverage module is about tracking request and response validation to assess if all parts of the API description have been tested. Currently it does not care about unknown requests that are not part of any API description.
Defined Under Namespace
Classes: CoveredRequest, CoveredResponse, HtmlReporter, Plan, Result, RouteTask, TerminalReporter, Tracker
Constant Summary collapse
- TerminalFormatter =
Deprecated.
Use TerminalReporter instead.
TerminalReporter
Class Method Summary collapse
-
.reset ⇒ Object
Clear current coverage run.
- .result ⇒ Object
- .start(skip_response: nil, skip_route: nil) ⇒ Object
- .track_request(request, oad) ⇒ Object
- .track_response(response, _request, oad) ⇒ Object
Class Method Details
.reset ⇒ Object
Clear current coverage run
35 36 37 38 39 40 41 42 43 |
# File 'lib/openapi_first/test/coverage.rb', line 35 def reset @tracker = nil return unless @drb_uri service = DRb.fetch_server(@drb_uri) service&.stop_service @drb_uri = nil end |
.result ⇒ Object
85 86 87 |
# File 'lib/openapi_first/test/coverage.rb', line 85 def result Result.new(plans:, coverage:) end |
.start(skip_response: nil, skip_route: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/openapi_first/test/coverage.rb', line 24 def start(skip_response: nil, skip_route: nil) return if @drb_uri tracker = Tracker.new(Test.definitions, skip_response:, skip_route:) # We need a custom DRbServer (not using DRb.start_service) because otherwise # we'd conflict with Rails's DRb server @drb_uri = DRb::DRbServer.new(nil, tracker).uri end |
.track_request(request, oad) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/openapi_first/test/coverage.rb', line 45 def track_request(request, oad) return unless request.known? # The call to `track_request` may happen remotely in the main process that started # the coverage collection. # To make this work we need to keep arguments trivial, which is the reason the request # is wrapped in a CoveredRequest data object. # :nocov: return unless tracker # :nocov: tracker.track_request( oad.key, CoveredRequest.new( key: request.request_definition.key, error: request.error ) ) end |
.track_response(response, _request, oad) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/openapi_first/test/coverage.rb', line 65 def track_response(response, _request, oad) return unless response.known? # The call to `track_response` may happen remotely in the main process that started # the coverage collection. # To make this work we need to keep arguments trivial, which is the reason the response # is wrapped in a CoveredResponse data object. # :nocov: return unless tracker # :nocov: tracker.track_response( oad.key, CoveredResponse.new( key: response.response_definition.key, error: response.error ) ) end |