Skip to content

Instantly share code, notes, and snippets.

@stuartsaunders
Created December 20, 2010 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartsaunders/748092 to your computer and use it in GitHub Desktop.
Save stuartsaunders/748092 to your computer and use it in GitHub Desktop.
OS X 10.6.5 + Spork 0.8.4 + RSpec 1.3.1 = DRb.start_service('druby://localhost:0') SocketError
require "drb/drb"
module Spec
module Runner
# Facade to run specs by connecting to a DRB server
class DrbCommandLine
def self.port(options)
(options.drb_port || ENV["RSPEC_DRB"] || 8989).to_i
end
# Runs specs on a DRB server. Note that this API is similar to that of
# CommandLine - making it possible for clients to use both interchangeably.
def self.run(options)
begin
begin; \
# Workaround http://www.ruby-forum.com/topic/154556
DRb.start_service("druby://127.0.0.1:0"); \
rescue SocketError, Errno::EADDRNOTAVAIL; \
DRb.start_service("druby://:0"); \
end
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{port(options)}")
spec_server.run(options.argv, options.error_stream, options.output_stream)
true
rescue DRb::DRbConnError
options.error_stream.puts "No server is running"
false
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment