diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/generators/rails/app/templates/test/test_helper.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/railtie.rb | 2 | ||||
-rw-r--r-- | railties/test/application/test_test.rb | 17 |
3 files changed, 19 insertions, 1 deletions
diff --git a/railties/lib/generators/rails/app/templates/test/test_helper.rb b/railties/lib/generators/rails/app/templates/test/test_helper.rb index 45b551fc7d..005149eba0 100644 --- a/railties/lib/generators/rails/app/templates/test/test_helper.rb +++ b/railties/lib/generators/rails/app/templates/test/test_helper.rb @@ -1,4 +1,5 @@ ENV["RAILS_ENV"] = "test" +require 'test/unit' require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'rails/test_help' diff --git a/railties/lib/rails/test_unit/railtie.rb b/railties/lib/rails/test_unit/railtie.rb index f7f07ac053..b0a4b460af 100644 --- a/railties/lib/rails/test_unit/railtie.rb +++ b/railties/lib/rails/test_unit/railtie.rb @@ -16,7 +16,7 @@ module Rails initializer "test_unit.backtrace_cleaner" do # TODO: Figure out how to get the Rails::BacktraceFilter into minitest/unit - unless defined?(Minitest) || ENV['BACKTRACE'] + if defined?(Test::Unit::Util::BacktraceFilter) && ENV['BACKTRACE'].nil? require 'rails/backtrace_cleaner' Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit } end diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb index 37175783d8..de316a6fd0 100644 --- a/railties/test/application/test_test.rb +++ b/railties/test/application/test_test.rb @@ -23,6 +23,23 @@ module ApplicationTests run_test 'unit/foo_test.rb' end + # Run just in Ruby < 1.9 + if defined?(Test::Unit::Util::BacktraceFilter) + test "adds backtrace cleaner" do + app_file 'test/unit/backtrace_test.rb', <<-RUBY + require 'test_helper' + + class FooTest < ActiveSupport::TestCase + def test_truth + assert Test::Unit::Util::BacktraceFilter.ancestors.include?(Rails::BacktraceFilterForTestUnit) + end + end + RUBY + + run_test 'unit/backtrace_test.rb' + end + end + test "integration test" do controller 'posts', <<-RUBY class PostsController < ActionController::Base |