class Cucumber::Cli::DRbClient

Runs features on a DRB server, originally created with Spork compatibility in mind.

Constants

DEFAULT_PORT

Public Class Methods

run(args, error_stream, out_stream, port = nil) click to toggle source
# File lib/cucumber/cli/drb_client.rb, line 14
def run(args, error_stream, out_stream, port = nil)
  port ||= ENV["CUCUMBER_DRB"] || DEFAULT_PORT

  setup_support_for_io_streams_over_drb

  feature_server = DRbObject.new_with_uri("druby://127.0.0.1:#{port}")
  cloned_args = [] # I have no idea why this is needed, but if the regular args are sent then DRb magically transforms it into a DRb object - not an array
  args.each { |arg| cloned_args << arg }
  feature_server.run(cloned_args, error_stream, out_stream)
rescue DRb::DRbConnError => e
  raise DRbClientError, "No DRb server is running."
end

Private Class Methods

setup_support_for_io_streams_over_drb() click to toggle source
# File lib/cucumber/cli/drb_client.rb, line 28
def setup_support_for_io_streams_over_drb
  # See http://redmine.ruby-lang.org/issues/show/496 as to why we specify localhost:0
  begin
    DRb.start_service("druby://localhost:0")
  rescue SocketError, Errno::EADDRNOTAVAIL
    # Ruby-1.8.7 on snow leopard doesn't like localhost:0 - but just :0
    # seems to work just fine
    DRb.start_service("druby://:0")
  end
end