haml--haml/test/linked_rails.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

2008-10-27 17:19:52 +00: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 22:39:42 +00:00
$:.unshift linked_rails + '/railties/lib'
2008-10-27 17:19:52 +00:00
end
require 'rubygems'
require 'action_pack'
2008-10-27 17:19:52 +00:00
require 'action_controller'
require 'action_view'
2010-05-12 22:49:42 +00:00
if ActionPack::VERSION::MAJOR >= 3
2010-05-12 22:49:42 +00:00
# Necessary for Rails 3
require 'rails'
else
# Necessary for Rails 2.3.*
require 'initializer'
2010-05-12 22:49:42 +00:00
end
2010-05-18 03:01:43 +00:00
if defined?(Rails::Application) # Rails 3
class TestApp < Rails::Application
config.root = File.join(File.dirname(__FILE__), "../..")
end
Rails.application = TestApp
elsif defined?(RAILS_ROOT)
RAILS_ROOT.replace(File.join(File.dirname(__FILE__), "../.."))
else
RAILS_ROOT = File.join(File.dirname(__FILE__), "../..")
2010-05-18 03:01:43 +00:00
end
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'
eval(File.read(plugin + '/init.rb'))
end