Module: RSpecTracer::RSpecRunner

Defined in:
lib/rspec_tracer/rspec_runner.rb

Instance Method Summary collapse

Instance Method Details

#run_specs(example_groups) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rspec_tracer/rspec_runner.rb', line 5

def run_specs(example_groups)
  actual_count = RSpec.world.example_count
  RSpecTracer.no_examples = actual_count.zero?

  if RSpecTracer.no_examples
    RSpecTracer.running = true

    super(example_groups)

    return
  end

  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  filtered_examples, filtered_example_groups = RSpecTracer.filter_examples

  RSpec.world.instance_variable_set(:@filtered_examples, filtered_examples)
  RSpec.world.instance_variable_set(:@example_groups, filtered_example_groups)

  current_count = RSpec.world.example_count
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  elapsed = RSpecTracer::TimeFormatter.format_time(ending - starting)

  puts
  puts <<-EXAMPLES.strip.gsub(/\s+/, ' ')
    RSpec tracer is running #{current_count} examples (actual: #{actual_count},
    skipped: #{actual_count - current_count}) (took #{elapsed})
  EXAMPLES

  RSpecTracer.running = true

  super(filtered_example_groups)
end