Class: TurboTests::JsonRowsFormatter
- Inherits:
-
Object
- Object
- TurboTests::JsonRowsFormatter
- Defined in:
- lib/turbo_tests/json_rows_formatter.rb
Overview
An RSpec formatter used for each subprocess during parallel test execution
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #close(notification) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
- #example_to_json(example) ⇒ Object
- #exception_to_json(exception) ⇒ Object
- #execution_result_to_json(result) ⇒ Object
-
#initialize(output) ⇒ JsonRowsFormatter
constructor
A new instance of JsonRowsFormatter.
- #message(notification) ⇒ Object
- #seed(notification) ⇒ Object
- #stack_frame_to_json(frame) ⇒ Object
Constructor Details
#initialize(output) ⇒ JsonRowsFormatter
Returns a new instance of JsonRowsFormatter.
18 19 20 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 18 def initialize(output) @output = output end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
16 17 18 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 16 def output @output end |
Instance Method Details
#close(notification) ⇒ Object
80 81 82 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 80 def close(notification) output_row(type: :close) end |
#example_failed(notification) ⇒ Object
72 73 74 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 72 def example_failed(notification) output_row(type: :example_failed, example: example_to_json(notification.example)) end |
#example_passed(notification) ⇒ Object
64 65 66 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 64 def example_passed(notification) output_row(type: :example_passed, example: example_to_json(notification.example)) end |
#example_pending(notification) ⇒ Object
68 69 70 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 68 def example_pending(notification) output_row(type: :example_pending, example: example_to_json(notification.example)) end |
#example_to_json(example) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 48 def example_to_json(example) { execution_result: execution_result_to_json(example.execution_result), location: example.location, full_description: example.full_description, metadata: { shared_group_inclusion_backtrace: example.[:shared_group_inclusion_backtrace].map(&method(:stack_frame_to_json)), extra_failure_lines: example.[:extra_failure_lines], run_duration_ms: example.[:run_duration_ms], process_pid: Process.pid, }, location_rerun_argument: example.location_rerun_argument, } end |
#exception_to_json(exception) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 22 def exception_to_json(exception) if exception { class_name: exception.class.name.to_s, backtrace: exception.backtrace, message: exception., cause: exception_to_json(exception.cause), } end end |
#execution_result_to_json(result) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 33 def execution_result_to_json(result) { example_skipped?: result.example_skipped?, pending_message: result., status: result.status, pending_fixed?: result.pending_fixed?, exception: exception_to_json(result.exception), pending_exception: exception_to_json(result.pending_exception), } end |
#message(notification) ⇒ Object
84 85 86 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 84 def (notification) output_row(type: :message, message: notification.) end |
#seed(notification) ⇒ Object
76 77 78 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 76 def seed(notification) output_row(type: :seed, seed: notification.seed) end |
#stack_frame_to_json(frame) ⇒ Object
44 45 46 |
# File 'lib/turbo_tests/json_rows_formatter.rb', line 44 def stack_frame_to_json(frame) { shared_group_name: frame.shared_group_name, inclusion_location: frame.inclusion_location } end |