Class: ZSpec::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/zspec/worker.rb

Constant Summary collapse

APPLICATION_FILE =
"/app/config/application.rb".freeze

Instance Method Summary collapse

Constructor Details

#initialize(queue:, tracker:) ⇒ Worker

Returns a new instance of Worker.



5
6
7
8
# File 'lib/zspec/worker.rb', line 5

def initialize(queue:, tracker:)
  @queue   = queue
  @tracker = tracker
end

Instance Method Details

#workObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zspec/worker.rb', line 10

def work
  require APPLICATION_FILE if File.exist? APPLICATION_FILE
  @queue.pending_queue.each do |spec|
    next if spec.nil?
    puts "running: #{spec}"
    fork do
      run_specs(spec, StringIO.new)
    end
    Process.waitall
    fail if $?.exitstatus != 0
    puts "completed: #{spec}"
  end
end