diff options
author | José Valim <jose.valim@gmail.com> | 2010-02-07 14:36:50 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-07 14:51:23 +0100 |
commit | 518b4ff478984b74085239b0aa69fe67f7c01d9a (patch) | |
tree | e2e3c5aa614c7c9a00b480428057afd84de13435 | |
parent | d6ae930c9cfacf50d65b2880ac21efe80801a33d (diff) | |
download | rails-518b4ff478984b74085239b0aa69fe67f7c01d9a.tar.gz rails-518b4ff478984b74085239b0aa69fe67f7c01d9a.tar.bz2 rails-518b4ff478984b74085239b0aa69fe67f7c01d9a.zip |
Check if Test::Unit is defined before adding backtrace filter.
-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 |