Class: CukeForker::WebDriver::ParallelPortManager

Inherits:
AbstractListener
  • Object
show all
Defined in:
lib/cukeforker-webdriver/parallel_port_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(max) ⇒ ParallelPortManager

Returns a new instance of ParallelPortManager.



6
7
8
9
10
11
12
# File 'lib/cukeforker-webdriver/parallel_port_manager.rb', line 6

def initialize(max)
  @port_pool = CukeForker::WebDriver::PortPool.new max
  @available_ports = []
  until @available_ports.length == max
    @available_ports << @port_pool.get
  end
end

Instance Method Details

#on_worker_finished(worker) ⇒ Object



23
24
25
# File 'lib/cukeforker-webdriver/parallel_port_manager.rb', line 23

def on_worker_finished(worker)
  @available_ports << worker.data.web_driver_port
end

#on_worker_forked(worker) ⇒ Object



18
19
20
21
# File 'lib/cukeforker-webdriver/parallel_port_manager.rb', line 18

def on_worker_forked(worker)
  require_relative 'capybara/driver'
  ENV['web_driver_port'] = worker.data.web_driver_port.to_s
end

#on_worker_starting(worker) ⇒ Object



14
15
16
# File 'lib/cukeforker-webdriver/parallel_port_manager.rb', line 14

def on_worker_starting(worker)
  worker.data.web_driver_port = @available_ports.shift
end