From 6b086449bebc4ecbd11887c74f0c16c0c38089dc Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 29 Sep 2009 16:07:29 -0700 Subject: Fix the broken railties isolation tests --- railties/test/isolation/abstract_unit.rb | 38 +++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'railties/test/isolation/abstract_unit.rb') diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index d3fc1f3395..bc1b43acaa 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -14,10 +14,6 @@ require 'test/unit' # TODO: Remove setting this magic constant RAILS_FRAMEWORK_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../..") -# These load paths usually get set inside of boot.rb -$:.unshift "#{RAILS_FRAMEWORK_ROOT}/railties/lib" -$:.unshift "#{RAILS_FRAMEWORK_ROOT}/actionpack/lib" - # These files do not require any others and are needed # to run the tests require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/testing/isolation" @@ -71,8 +67,23 @@ module TestHelpers end module Generation - def build_app + def build_app(options = {}) + FileUtils.rm_rf(app_path) FileUtils.cp_r(tmp_path('app_template'), app_path) + + # Delete the initializers unless requested + unless options[:initializers] + Dir["#{app_path}/config/initializers/*.rb"].each do |initializer| + File.delete(initializer) + end + end + + environment = File.read("#{app_path}/config/environment.rb") + if environment =~ /(\n\s*end\s*)\Z/ + File.open("#{app_path}/config/environment.rb", 'w') do |f| + f.puts $` + %'\nconfig.action_controller.session = { :key => "_myapp_session", :secret => "bac838a849c1d5c4de2e6a50af826079" }\n' + $1 + end + end end def app_file(path, contents) @@ -84,6 +95,23 @@ module TestHelpers def controller(name, contents) app_file("app/controllers/#{name}_controller.rb", contents) end + + def boot_rails + # return if defined?(RAILS) + # TODO: Get this working with boot.rb + $:.unshift "#{RAILS_FRAMEWORK_ROOT}/railties/lib" + Object.class_eval <<-RUBY + RAILS_ROOT = "#{app_path}" + module ::Rails + def self.vendor_rails? + true + end + end + RUBY + require "rails" + Rails::Initializer.run(:install_gem_spec_stubs) + Rails::GemDependency.add_frozen_gem_path + end end end -- cgit v1.2.3