public
Clone URL: git://github.com/robbyrussell/rubyurl.git
Search Repo:
rmm5t (author)
Sun Mar 02 14:42:29 -0800 2008
commit  26886b6a75f2c37e6a056058e490e23b04054dcf
tree    32683fd7490fde843e3186728d5791158b9e17b3
parent  20157bf6ac66a72928a455a935a6e8e56bf6110e
rubyurl / script / spec_server
100755 45 lines (38 sloc) 1.388 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
 
# This is based on Florian Weber's TDDMate
 
module Spec
  module Runner
    class RailsSpecServer
      def run(args, stderr, stdout)
      $stdout = stdout
      $stderr = stderr
 
        ::Dispatcher.reset_application!
        ::Dependencies.mechanism = :load
        require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
        load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
    
        ::Spec::Runner::CommandLine.run(args, stderr, stdout, false, true)
      end
    end
  end
end
puts "Loading Rails environment"
 
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'dispatcher'
 
def restart_test_server
  puts "restarting"
  config = ::Config::CONFIG
  ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
  command_line = [ruby, $0, ARGV].flatten.join(' ')
  exec(command_line)
end
 
trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
puts "Ready"
DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new)
DRb.thread.join