Upgraded Rails and RSpec
[monkeycharger.git] / script / spec_server
blobdeac38a1a29d338a48bd125245f8c4f25365a2d4
1 #!/usr/bin/env ruby
2 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
3 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
4 require 'rubygems'
5 require 'drb/drb'
6 require 'rbconfig'
7 require 'spec'
9 # This is based on Florian Weber's TDDMate
11 module Spec
12 module Runner
13 class RailsSpecServer
14 def run(args, stderr, stdout)
15 $stdout = stdout
16 $stderr = stderr
18 ::Dispatcher.reset_application!
19 ::Dependencies.mechanism = :load
20 require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
21 load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
23 ::Spec::Runner::CommandLine.run(args, stderr, stdout, false, true)
24 end
25 end
26 end
27 end
28 puts "Loading Rails environment"
30 ENV["RAILS_ENV"] = "test"
31 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
32 require 'dispatcher'
34 def restart_test_server
35 puts "restarting"
36 config = ::Config::CONFIG
37 ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
38 command_line = [ruby, $0, ARGV].flatten.join(' ')
39 exec(command_line)
40 end
42 trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
43 puts "Ready"
44 DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new)
45 DRb.thread.join