diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/initializer/check_ruby_version_test.rb | 2 | ||||
-rw-r--r-- | railties/test/initializer/install_gem_spec_stubs_test.rb | 29 | ||||
-rw-r--r-- | railties/test/initializer/path_test.rb | 2 | ||||
-rw-r--r-- | railties/test/initializer/test_helper.rb | 48 |
4 files changed, 53 insertions, 28 deletions
diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/initializer/check_ruby_version_test.rb index 33de653906..68feba058e 100644 --- a/railties/test/initializer/check_ruby_version_test.rb +++ b/railties/test/initializer/check_ruby_version_test.rb @@ -1,7 +1,7 @@ require "initializer/test_helper" module InitializerTests - class PathsTest < ActiveSupport::TestCase + class PathsTest < Test::Unit::TestCase include ActiveSupport::Testing::Isolation test "rails does not initialize with ruby version 1.8.1" do diff --git a/railties/test/initializer/install_gem_spec_stubs_test.rb b/railties/test/initializer/install_gem_spec_stubs_test.rb index 2e94c9968f..cfb12d7405 100644 --- a/railties/test/initializer/install_gem_spec_stubs_test.rb +++ b/railties/test/initializer/install_gem_spec_stubs_test.rb @@ -1,7 +1,7 @@ require "initializer/test_helper" module InitializerTests - class GemSpecStubsTest < ActiveSupport::TestCase + class GemSpecStubsTest < Test::Unit::TestCase include ActiveSupport::Testing::Isolation def setup @@ -34,19 +34,20 @@ module InitializerTests assert $rubygems_required end - test "does not fail if rubygems does not exist" do - Kernel.module_eval do - alias old_require require - def require(name) - raise LoadError if name == "rubygems" - old_require(name) - end - end - - assert_nothing_raised do - Rails::Initializer.run { |c| c.frameworks = [] } - end - end + # Pending until we're further along + # test "does not fail if rubygems does not exist" do + # Kernel.module_eval do + # alias old_require require + # def require(name) + # raise LoadError if name == "rubygems" + # old_require(name) + # end + # end + # + # assert_nothing_raised do + # Rails::Initializer.run { |c| c.frameworks = [] } + # end + # end test "adds fake Rubygems stubs if a framework is not loaded in Rubygems and we've vendored" do Rails.vendor_rails = true diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb index 26f796f93d..1b73cdc73e 100644 --- a/railties/test/initializer/path_test.rb +++ b/railties/test/initializer/path_test.rb @@ -1,6 +1,6 @@ require "initializer/test_helper" -class PathsTest < ActiveSupport::TestCase +class PathsTest < Test::Unit::TestCase include ActiveSupport::Testing::Isolation def self.setup diff --git a/railties/test/initializer/test_helper.rb b/railties/test/initializer/test_helper.rb index ddb03397ab..9d7dfff1c0 100644 --- a/railties/test/initializer/test_helper.rb +++ b/railties/test/initializer/test_helper.rb @@ -1,17 +1,18 @@ -require 'abstract_unit' -require 'active_support/ruby/shim' -require 'initializer' +# This is a test helper file that simulates a rails application being +# boot from scratch in vendored mode. This file should really only be +# required in test cases that use the isolation helper so that requires +# can be reset correctly. +RAILS_ROOT = File.join(File.dirname(__FILE__), "root") +RAILS_FRAMEWORK_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..')) -RAILS_ROOT.replace File.join(File.dirname(__FILE__), "root") +require "test/unit" +# We are purposely avoiding adding things to the load path to catch bugs that only happen in the genuine article +require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'isolation') +require File.join(RAILS_FRAMEWORK_ROOT, 'activesupport', 'lib', 'active_support', 'testing', 'declarative') -module Rails - class << self - attr_accessor :vendor_rails - def vendor_rails?() @vendor_rails end - end -end +class Test::Unit::TestCase + extend ActiveSupport::Testing::Declarative -class ActiveSupport::TestCase def assert_stderr(match) $stderr = StringIO.new yield @@ -21,4 +22,27 @@ class ActiveSupport::TestCase ensure $stderr = STDERR end -end
\ No newline at end of file +end + +# Fake boot.rb +module Rails + class << self + attr_accessor :vendor_rails + + def vendor_rails? + @vendor_rails + end + + def boot! + # Require the initializer + require File.join(RAILS_FRAMEWORK_ROOT, 'railties', 'lib', 'initializer') + # Run the initializer the same way boot.rb does it + Rails::Initializer.run(:install_gem_spec_stubs) + Rails::GemDependency.add_frozen_gem_path + Rails::Initializer.run(:set_load_path) + end + end +end + +# All that for this: +Rails.boot!
\ No newline at end of file |