From f9382cd7948c75a9ca0772ee2795699577b06d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 6 Jan 2012 15:54:22 -0300 Subject: [PATCH 1/4] Test::Unit::Util::BacktraceFilter is never defined --- railties/lib/rails/test_help.rb | 5 ----- railties/test/backtrace_cleaner_test.rb | 28 ------------------------- 2 files changed, 33 deletions(-) diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 1b5ab549bebc5..0b2842837fd60 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -7,11 +7,6 @@ require 'action_controller/test_case' require 'action_dispatch/testing/integration' -if defined?(Test::Unit::Util::BacktraceFilter) && ENV['BACKTRACE'].nil? - require 'rails/backtrace_cleaner' - Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit } -end - if defined?(MiniTest) # Enable turn if it is available begin diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb index 80077378db93c..cbe7d35f6dead 100644 --- a/railties/test/backtrace_cleaner_test.rb +++ b/railties/test/backtrace_cleaner_test.rb @@ -1,34 +1,6 @@ require 'abstract_unit' require 'rails/backtrace_cleaner' -if defined? Test::Unit::Util::BacktraceFilter - class TestWithBacktrace - include Test::Unit::Util::BacktraceFilter - include Rails::BacktraceFilterForTestUnit - end - - class BacktraceCleanerFilterTest < ActiveSupport::TestCase - def setup - @test = TestWithBacktrace.new - @backtrace = [ './test/rails/benchmark_test.rb', './test/rails/dependencies.rb', '/opt/local/lib/ruby/kernel.rb' ] - end - - test "test with backtrace should use the rails backtrace cleaner to clean" do - Rails.stubs(:backtrace_cleaner).returns(stub(:clean)) - Rails.backtrace_cleaner.expects(:clean).with(@backtrace, nil) - @test.send(:filter_backtrace, @backtrace) - end - - test "filter backtrace should have the same arity as Test::Unit::Util::BacktraceFilter" do - assert_nothing_raised do - @test.send(:filter_backtrace, @backtrace, '/opt/local/lib') - end - end - end -else - $stderr.puts 'No BacktraceFilter for minitest' -end - if defined? Gem class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase def setup From ce84df020a9665348912b42661c906a332d55220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 6 Jan 2012 15:54:40 -0300 Subject: [PATCH 2/4] MiniTest is always defined in this case --- railties/lib/rails/test_help.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 0b2842837fd60..87326e47a1d41 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -7,16 +7,14 @@ require 'action_controller/test_case' require 'action_dispatch/testing/integration' -if defined?(MiniTest) - # Enable turn if it is available - begin - require 'turn' +# Enable turn if it is available +begin + require 'turn' - if MiniTest::Unit.respond_to?(:use_natural_language_case_names=) - MiniTest::Unit.use_natural_language_case_names = true - end - rescue LoadError + if MiniTest::Unit.respond_to?(:use_natural_language_case_names=) + MiniTest::Unit.use_natural_language_case_names = true end +rescue LoadError end if defined?(ActiveRecord::Base) From 3d4754f131ee2e64ae4e4297c069293f1448e1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 6 Jan 2012 16:07:22 -0300 Subject: [PATCH 3/4] Use ActiveModel::TestCase instead of Test::Unit:TestCase --- activemodel/test/cases/naming_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index acda989eec34e..1e14d83bcb452 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -210,7 +210,7 @@ def test_i18n_key end end -class NamingHelpersTest < Test::Unit::TestCase +class NamingHelpersTest < ActiveModel::TestCase def setup @klass = Contact @record = @klass.new @@ -276,7 +276,7 @@ def method_missing(method, *args) end end -class NameWithAnonymousClassTest < Test::Unit::TestCase +class NameWithAnonymousClassTest < ActiveModel::TestCase def test_anonymous_class_without_name_argument assert_raises(ArgumentError) do ActiveModel::Name.new(Class.new) From 185aa821d94308171d57e4e2cfffbcc312d01450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 6 Jan 2012 16:02:08 -0300 Subject: [PATCH 4/4] Whitespaces :scissors: --- .../lib/active_support/backtrace_cleaner.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 8f8deb9692d9d..e97bb25b9fcdc 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -1,11 +1,11 @@ module ActiveSupport - # Backtraces often include many lines that are not relevant for the context under review. This makes it hard to find the + # Backtraces often include many lines that are not relevant for the context under review. This makes it hard to find the # signal amongst the backtrace noise, and adds debugging time. With a BacktraceCleaner, filters and silencers are used to # remove the noisy lines, so that only the most relevant lines remain. # # Filters are used to modify lines of data, while silencers are used to remove lines entirely. The typical filter use case - # is to remove lengthy path information from the start of each line, and view file paths relevant to the app directory - # instead of the file system root. The typical silencer use case is to exclude the output of a noisy library from the + # is to remove lengthy path information from the start of each line, and view file paths relevant to the app directory + # instead of the file system root. The typical silencer use case is to exclude the output of a noisy library from the # backtrace, so that you can focus on the rest. # # ==== Example: @@ -15,9 +15,9 @@ module ActiveSupport # bc.add_silencer { |line| line =~ /mongrel|rubygems/ } # bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems # - # To reconfigure an existing BacktraceCleaner (like the default one in Rails) and show as much data as possible, you can - # always call BacktraceCleaner#remove_silencers!, which will restore the backtrace to a pristine state. If you - # need to reconfigure an existing BacktraceCleaner so that it does not filter or modify the paths of any lines of the + # To reconfigure an existing BacktraceCleaner (like the default one in Rails) and show as much data as possible, you can + # always call BacktraceCleaner#remove_silencers!, which will restore the backtrace to a pristine state. If you + # need to reconfigure an existing BacktraceCleaner so that it does not filter or modify the paths of any lines of the # backtrace, you can call BacktraceCleaner#remove_filters! These two methods will give you a completely untouched backtrace. # # Inspired by the Quiet Backtrace gem by Thoughtbot. @@ -50,7 +50,7 @@ def add_filter(&block) @filters << block end - # Adds a silencer from the block provided. If the silencer returns true for a given line, it will be excluded from + # Adds a silencer from the block provided. If the silencer returns true for a given line, it will be excluded from # the clean backtrace. # # Example: