Class: RSpecTurbo::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_turbo/runner.rb

Overview

Top-level orchestration: parse argv, set up the test databases, discover and plan the spec files, hand execution to the Executor, then print the report and (optionally) merge coverage. Exits non-zero on any failure.

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



10
11
12
13
# File 'lib/rspec_turbo/runner.rb', line 10

def initialize(argv)
  @options = Options.new(argv)
  @workers = Config.workers
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rspec_turbo/runner.rb', line 15

def run
  FileUtils.mkdir_p(Config.log_dir)
  print_header

  setup_databases
  planner = plan(discover_files)

  FileUtils.rm_rf("coverage") if Config.coverage?

  display = Display.new(planner)
  executor = Executor.new(planner, display, @options.rspec_options)
  results = executor.run
  wall_total = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - executor.wall_started).round

  display.print_report(results, wall_total, @workers)
  merge_coverage if Config.coverage?

  exit((results.any? { |r| r[:status] == "FAIL" }) ? 1 : 0)
end