Got all the railties tests to pass, rails must boot!

This commit is contained in:
Yehuda Katz + Carl Lerche 2009-06-19 12:12:56 -07:00
parent 30baaac546
commit 9d398f4827
4 changed files with 34 additions and 3 deletions

View File

@ -4,6 +4,8 @@ require 'rails/version'
require 'rails/gem_dependency'
require 'rails/rack'
RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless defined?(RAILS_ENV)
module Rails
class Configuration
attr_accessor :cache_classes, :load_paths, :eager_load_paths, :framework_paths,
@ -13,11 +15,13 @@ module Rails
:i18n, :gems
def initialize
set_root_path!
@framework_paths = []
@load_once_paths = []
@after_initialize_blocks = []
@plugin_paths = []
@loaded_plugins = []
@plugin_paths = default_plugin_paths
@frameworks = default_frameworks
@plugin_loader = default_plugin_loader
@plugin_locators = default_plugin_locators
@ -29,6 +33,24 @@ module Rails
@after_initialize_blocks << blk if blk
end
def set_root_path!
raise 'RAILS_ROOT is not set' unless defined?(RAILS_ROOT)
raise 'RAILS_ROOT is not a directory' unless File.directory?(RAILS_ROOT)
self.root_path =
# Pathname is incompatible with Windows, but Windows doesn't have
# real symlinks so File.expand_path is safe.
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
File.expand_path(RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
Pathname.new(RAILS_ROOT).realpath.to_s
end
RAILS_ROOT.replace self.root_path
end
def framework_paths
paths = %w(railties railties/lib activesupport/lib)
paths << 'actionpack/lib' if frameworks.include?(:action_controller) || frameworks.include?(:action_view)
@ -54,6 +76,10 @@ module Rails
[ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ]
end
def default_plugin_paths
["#{root_path}/vendor/plugins"]
end
def default_plugin_loader
require 'rails/plugin/loader'
Plugin::Loader

View File

@ -27,7 +27,8 @@ class PluginFileSystemLocatorTest < Test::Unit::TestCase
# We need to add our testing plugin directory to the plugin paths so
# the locator knows where to look for our plugins
@configuration.plugin_paths << plugin_fixture_root_path
@initializer = Rails::Initializer.new(@configuration)
@initializer = Rails::Initializer.default
@initializer.config = @configuration
@locator = Rails::Plugin::FileSystemLocator.new(@initializer)
@valid_plugin_path = plugin_fixture_path('default/stubby')
@empty_plugin_path = plugin_fixture_path('default/empty')

View File

@ -2,7 +2,8 @@ require 'plugin_test_helper'
class PluginTest < Test::Unit::TestCase
def setup
@initializer = Rails::Initializer.new(Rails::Configuration.new)
@initializer = Rails::Initializer.default
@initializer.config = Rails::Configuration.new
@valid_plugin_path = plugin_fixture_path('default/stubby')
@empty_plugin_path = plugin_fixture_path('default/empty')
@gemlike_plugin_path = plugin_fixture_path('default/gemlike')

View File

@ -50,6 +50,9 @@ class RailsGeneratorTest < Test::Unit::TestCase
def setup
ActiveRecord::Base.pluralize_table_names = true
@initializer = Rails::Initializer.default
@initializer.config = Rails.configuration
@initializer.run(:set_root_path)
end
def test_sources