Class: OpenapiMinitest::ResultCollector
- Inherits:
-
Object
- Object
- OpenapiMinitest::ResultCollector
- Includes:
- MonitorMixin, Singleton
- Defined in:
- lib/openapi_minitest/result_collector.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ ResultCollector
constructor
A new instance of ResultCollector.
- #operations ⇒ Object
- #record(request:, response:, schema:, summary:, description:, tags:, operation_id:, deprecated:, test_name:) ⇒ Object
- #reset! ⇒ Object
- #responses ⇒ Object
Constructor Details
#initialize ⇒ ResultCollector
Returns a new instance of ResultCollector.
12 13 14 15 |
# File 'lib/openapi_minitest/result_collector.rb', line 12 def initialize super # MonitorMixin requires super reset! end |
Instance Method Details
#empty? ⇒ Boolean
68 69 70 |
# File 'lib/openapi_minitest/result_collector.rb', line 68 def empty? synchronize { @operations.empty? } end |
#operations ⇒ Object
60 61 62 |
# File 'lib/openapi_minitest/result_collector.rb', line 60 def operations synchronize { @operations } end |
#record(request:, response:, schema:, summary:, description:, tags:, operation_id:, deprecated:, test_name:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/openapi_minitest/result_collector.rb', line 24 def record(request:, response:, schema:, summary:, description:, tags:, operation_id:, deprecated:, test_name:) synchronize do method = request.request_method.downcase path = normalize_path(request.path) key = "#{method} #{path}" # Store operation metadata (first one wins for summary, tags merge) @operations[key] ||= { method: method, path: path, summary: summary, tags: [], operation_id: operation_id, deprecated: deprecated, parameters: extract_parameters(request, path), requires_auth: (request) } # Merge tags from all tests @operations[key][:tags] = (@operations[key][:tags] + ).uniq # Store response data grouped by status status = response.status.to_s @responses[key] ||= {} @responses[key][status] ||= [] @responses[key][status] << { description: description || default_description(response.status), schema: schema, example: parse_body(response.body), test_name: test_name, request_example: extract_request_example(request) } end end |
#reset! ⇒ Object
17 18 19 20 21 22 |
# File 'lib/openapi_minitest/result_collector.rb', line 17 def reset! synchronize do @operations = {} # "METHOD /path" => operation data @responses = {} # "METHOD /path" => { status => [response_data] } end end |
#responses ⇒ Object
64 65 66 |
# File 'lib/openapi_minitest/result_collector.rb', line 64 def responses synchronize { @responses } end |