2008-10-27 10:19:52 -07:00
|
|
|
# allows testing with edge Rails by creating a test/rails symlink
|
|
|
|
linked_rails = File.dirname(__FILE__) + '/rails'
|
|
|
|
|
|
|
|
if File.exists?(linked_rails) && !$:.include?(linked_rails + '/activesupport/lib')
|
|
|
|
puts "[ using linked Rails ]"
|
|
|
|
$:.unshift linked_rails + '/activesupport/lib'
|
|
|
|
$:.unshift linked_rails + '/actionpack/lib'
|
2010-05-12 15:39:42 -07:00
|
|
|
$:.unshift linked_rails + '/railties/lib'
|
2008-10-27 10:19:52 -07:00
|
|
|
end
|
2009-11-04 15:17:34 -08:00
|
|
|
require 'rubygems'
|
2011-09-20 13:28:22 -07:00
|
|
|
require 'action_pack'
|
2008-10-27 10:19:52 -07:00
|
|
|
require 'action_controller'
|
|
|
|
require 'action_view'
|
2010-05-12 15:49:42 -07:00
|
|
|
|
2011-09-20 13:28:22 -07:00
|
|
|
if ActionPack::VERSION::MAJOR >= 3
|
2010-05-12 15:49:42 -07:00
|
|
|
# Necessary for Rails 3
|
|
|
|
require 'rails'
|
2011-09-20 13:28:22 -07:00
|
|
|
else
|
|
|
|
# Necessary for Rails 2.3.*
|
2010-05-24 02:13:17 -07:00
|
|
|
require 'initializer'
|
2010-05-12 15:49:42 -07:00
|
|
|
end
|
2009-10-15 23:12:41 -07:00
|
|
|
|
2010-05-17 20:01:43 -07:00
|
|
|
if defined?(Rails::Application) # Rails 3
|
|
|
|
class TestApp < Rails::Application
|
|
|
|
config.root = File.join(File.dirname(__FILE__), "../..")
|
|
|
|
end
|
|
|
|
Rails.application = TestApp
|
2010-05-24 02:13:17 -07:00
|
|
|
elsif defined?(RAILS_ROOT)
|
|
|
|
RAILS_ROOT.replace(File.join(File.dirname(__FILE__), "../.."))
|
|
|
|
else
|
|
|
|
RAILS_ROOT = File.join(File.dirname(__FILE__), "../..")
|
2010-05-17 20:01:43 -07:00
|
|
|
end
|
|
|
|
|
2009-10-15 23:12:41 -07:00
|
|
|
ActionController::Base.logger = Logger.new(nil)
|
|
|
|
|
|
|
|
# Load plugins from test/plugins.
|
|
|
|
# This will only work with very basic plugins,
|
|
|
|
# since we don't want to load the entirety of Rails.
|
|
|
|
Dir[File.dirname(__FILE__) + '/plugins/*'].each do |plugin|
|
|
|
|
$: << plugin + '/lib'
|
2010-05-24 02:13:17 -07:00
|
|
|
eval(File.read(plugin + '/init.rb'))
|
2009-10-15 23:12:41 -07:00
|
|
|
end
|