Class: RSpec::Core::DRbCommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/drb_command_line.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ DRbCommandLine

Returns a new instance of DRbCommandLine.



4
5
6
# File 'lib/rspec/core/drb_command_line.rb', line 4

def initialize(options)
  @options = options
end

Instance Method Details

#drb_portObject



8
9
10
# File 'lib/rspec/core/drb_command_line.rb', line 8

def drb_port
  @options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989
end

#run(err, out) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rspec/core/drb_command_line.rb', line 12

def run(err, out)
  begin
    begin
      DRb.start_service("druby://localhost:0")
    rescue SocketError, Errno::EADDRNOTAVAIL
      DRb.start_service("druby://:0")
    end
    spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_port}")
    spec_server.run(@options.drb_argv, err, out)
    true
  rescue DRb::DRbConnError
    err.puts "No DRb server is running. Running in local process instead ..."
    false
  end
end