Class: RSpecQueue::WorkerRunner

Inherits:
RSpec::Core::Runner
  • Object
show all
Defined in:
lib/rspec_queue/worker_runner.rb

Instance Method Summary collapse

Instance Method Details

#run_specs(example_groups) ⇒ Object



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
# File 'lib/rspec_queue/worker_runner.rb', line 7

def run_specs(example_groups)
  example_group_hash = example_groups.map { |example_group|
    [example_group.id, example_group]
  }.to_h

  RSpecQueue::Configuration.instance.server_socket = ENV["RSPEC_QUEUE_SERVER_ADDRESS"]
  RSpecQueue::Configuration.call_after_worker_spawn_hooks(ENV["RSPEC_QUEUE_WORKER_ID"])

  worker = RSpecQueue::Worker.new

  @configuration.with_suite_hooks do
    reporter = @configuration.reporter

    while(worker.has_work?)
      # can we pass in a custom reporter which instantly reports back
      # to the server?
      example_group_hash[worker.current_example].run(reporter)
    end

      # report the results of the examples run to the master process
    worker.finish(reporter)
  end

ensure
  Process.exit
end