aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authortony <tony>2009-03-24 09:59:12 +0000
committertony <tony>2009-03-24 09:59:12 +0000
commit5fbd7762d39c8f57c02eba576cf44a1448eeffb5 (patch)
treedb15466f6d86babaf80dcaf8377ca651b6b7d4c2 /script
parentd2757566559da38db0044495f582d9b495eaf8e7 (diff)
Pull in new script/spec_server
Diffstat (limited to 'script')
-rwxr-xr-xscript/spec_server60
1 files changed, 45 insertions, 15 deletions
diff --git a/script/spec_server b/script/spec_server
index cac91e2b8..1e839355f 100755
--- a/script/spec_server
+++ b/script/spec_server
@@ -1,32 +1,63 @@
#!/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'
require 'optparse'
-specmate = ENV['HOME'] + "/Library/Application\ Support/TextMate/Bundles/RSpec.tmbundle/Support/lib"
-if File.directory?(specmate)
- $LOAD_PATH.unshift(specmate)
- require 'text_mate_formatter'
-end
# This is based on Florian Weber's TDDMate
-
module Spec
module Runner
class RailsSpecServer
- def run(args, stderr, stdout)
- $stdout = stdout
- $stderr = stderr
+ def run(argv, stderr, stdout)
+ $stdout = stdout
+ $stderr = stderr
+
+ base = ActiveRecord::Base
+ def base.clear_reloadable_connections!
+ active_connections.each do |name, conn|
+ if conn.requires_reloading?
+ conn.disconnect!
+ active_connections.delete(name)
+ end
+ end
+ end
+
+ if ActionController.const_defined?(:Dispatcher)
+ dispatcher = ::ActionController::Dispatcher.new($stdout)
+ dispatcher.cleanup_application
+ elsif ::Dispatcher.respond_to?(:reset_application!)
+ ::Dispatcher.reset_application!
+ else
+ raise "Application reloading failed"
+ end
+ if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
+ Fixtures.reset_cache
+ end
- ::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)
+
+ if in_memory_database?
+ load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
+ ActiveRecord::Migrator.up('db/migrate') # use migrations
+ end
+
+ ::Spec::Runner::CommandLine.run(
+ ::Spec::Runner::OptionParser.parse(
+ argv,
+ $stderr,
+ $stdout
+ )
+ )
+ end
+
+ def in_memory_database?
+ ENV["RAILS_ENV"] == "test" and
+ ::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
+ ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
end
end
end
@@ -43,7 +74,7 @@ def restart_test_server
ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
command_line = [ruby, $0, ARGV].flatten.join(' ')
exec(command_line)
-end
+end
def daemonize(pid_file = nil)
return yield if $DEBUG
@@ -83,4 +114,3 @@ if options[:daemon]
else
exec_server.call
end
-