class TurboTests::JsonRowsFormatter
An RSpec formatter used for each subprocess during parallel test execution
Attributes
output[R]
Public Class Methods
new(output)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 38 def initialize(output) @output = output end
Public Instance Methods
close(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 91 def close(notification) output_row( type: :close ) end
example_failed(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 77 def example_failed(notification) output_row( type: :example_failed, example: example_to_json(notification.example) ) end
example_group_finished(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 56 def example_group_finished(notification) output_row( type: :group_finished, group: group_to_json(notification) ) end
example_group_started(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 49 def example_group_started(notification) output_row( type: :group_started, group: group_to_json(notification) ) end
example_passed(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 63 def example_passed(notification) output_row( type: :example_passed, example: example_to_json(notification.example) ) end
example_pending(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 70 def example_pending(notification) output_row( type: :example_pending, example: example_to_json(notification.example) ) end
message(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 97 def message(notification) output_row( type: :message, message: notification.message ) end
seed(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 84 def seed(notification) output_row( type: :seed, seed: notification.seed ) end
start(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 42 def start(notification) output_row( type: :load_summary, summary: load_summary_to_json(notification) ) end
Private Instance Methods
example_to_json(example)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 134 def example_to_json(example) { execution_result: execution_result_to_json(example.execution_result), location: example.location, description: example.description, full_description: example.full_description, metadata: { shared_group_inclusion_backtrace: example .metadata[:shared_group_inclusion_backtrace] .map { |frame| stack_frame_to_json(frame) } }, location_rerun_argument: example.location_rerun_argument } end
exception_to_json(exception)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 106 def exception_to_json(exception) if exception { class_name: exception.class.name.to_s, backtrace: exception.backtrace, message: exception.message, cause: exception_to_json(exception.cause) } end end
execution_result_to_json(result)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 117 def execution_result_to_json(result) { example_skipped?: result.example_skipped?, pending_message: result.pending_message, status: result.status, pending_fixed?: result.pending_fixed?, exception: exception_to_json(result.exception || result.pending_exception) } end
group_to_json(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 157 def group_to_json(notification) { group: { description: notification.group.description } } end
load_summary_to_json(notification)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 150 def load_summary_to_json(notification) { count: notification.count, load_time: notification.load_time, } end
output_row(obj)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 165 def output_row(obj) output.puts(obj.to_json) output.flush end
stack_frame_to_json(frame)
click to toggle source
# File lib/turbo_tests/json_rows_formatter.rb, line 127 def stack_frame_to_json(frame) { shared_group_name: frame.shared_group_name, inclusion_location: frame.inclusion_location } end