Sha256: cdeb0634a718c358d9e8d4b2ec881d6281abb3d4f8d429198f6f8489b574f419

Contents?: true

Size: 1.4 KB

Versions: 18

Compression:

Stored size: 1.4 KB

Contents

require "drb/drb"
# This code was taken from the RSpec project and slightly modified.

module Cucumber
  module Cli
    class DRbClientError < StandardError
    end
    # Runs features on a DRB server, originally created with Spork compatibility in mind.
    class DRbClient
      DEFAULT_PORT = 8990

      class << self

        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
        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
            # 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

      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
cucumber-0.8.3 lib/cucumber/cli/drb_client.rb
cucumber-0.8.2 lib/cucumber/cli/drb_client.rb
cucumber-0.8.1 lib/cucumber/cli/drb_client.rb
cucumber-0.8.0 lib/cucumber/cli/drb_client.rb
cucumber-0.7.3 lib/cucumber/cli/drb_client.rb
cucumber-0.7.2 lib/cucumber/cli/drb_client.rb
cucumber-0.7.1 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.8 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.7 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.6 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.5 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.4 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.3 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.2 lib/cucumber/cli/drb_client.rb
cucumber-0.7.0.beta.1 lib/cucumber/cli/drb_client.rb
cucumber-0.6.4 lib/cucumber/cli/drb_client.rb
cucumber-0.6.3 lib/cucumber/cli/drb_client.rb