Class: RSpecTurbo::ProgressReporter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/rspec_turbo/progress_reporter.rb

Overview

RSpec formatter loaded inside each worker process. Its only job is to write the running example count to RSPEC_TURBO_PROGRESS_FILE after every example, so the parent runner can sum the slots and draw a live progress bar.

Deliberately self-contained (no dependency on the rest of the gem) so it can be required by absolute path inside the spawned ‘rspec` process. The slowest files report is produced separately by slow_profile.rb.

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ ProgressReporter

Returns a new instance of ProgressReporter.



17
18
19
20
21
# File 'lib/rspec_turbo/progress_reporter.rb', line 17

def initialize(output)
  super
  @count = 0
  @progress_file = ENV["RSPEC_TURBO_PROGRESS_FILE"]
end

Instance Method Details

#example_finished(_notification) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/rspec_turbo/progress_reporter.rb', line 23

def example_finished(_notification)
  @count += 1
  return unless @progress_file

  File.write(@progress_file, @count.to_s)
rescue
  nil
end