Object
An abstract class that is implemented to create a server
(This was originally based off of spec_server.rb from rspec-rails (David Chelimsky), which was based on Florian Weber’s TDDMate)
# File lib/spork/server.rb, line 50
50: def abort
51: run_strategy.abort
52: end
Sets up signals and starts the DRb service. If it’s successful, it doesn’t return. Not ever. You don’t need to override this.
# File lib/spork/server.rb, line 24
24: def listen
25: raise RuntimeError, "you must call Spork.using_spork! before starting the server" unless Spork.using_spork?
26: trap("SIGINT") { sig_int_received }
27: trap("SIGTERM") { abort; exit!(0) }
28: trap("USR2") { abort; restart } if Signal.list.has_key?("USR2")
29: @drb_service = DRb.start_service("druby://127.0.0.1:#{port}", self)
30: Spork.each_run { @drb_service.stop_service } if @run_strategy.class == Spork::RunStrategy::Forking
31: stderr.puts "Spork is ready and listening on #{port}!"
32: stderr.flush
33: DRb.thread.join
34: end
This is the public facing method that is served up by DRb. To use it from the client side (in a testing framework):
DRb.start_service("druby://localhost:0") # this allows Ruby to do some magical stuff so you can pass an output stream over DRb.
# see http://redmine.ruby-lang.org/issues/show/496 to see why localhost:0 is used.
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:8989")
spec_server.run(options.argv, $stderr, $stdout)
When implementing a test server, don’t override this method: override run_tests instead.
# File lib/spork/server.rb, line 46
46: def run(argv, stderr, stdout)
47: run_strategy.run(argv, stderr, stdout)
48: end
# File lib/spork/server.rb, line 55
55: def restart
56: stderr.puts "restarting"
57: stderr.flush
58: config = ::Config::CONFIG
59: ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
60: command_line = [ruby, $0, ARGV].flatten.join(' ')
61: exec(command_line)
62: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.