diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/backtrace_cleaner.rb | 14 | ||||
-rw-r--r-- | activesupport/lib/active_support/test_case.rb | 33 | ||||
-rw-r--r-- | activesupport/test/abstract_unit.rb | 4 | ||||
-rw-r--r-- | activesupport/test/test_case_test.rb | 8 | ||||
-rw-r--r-- | activesupport/test/ts_isolated.rb | 2 |
5 files changed, 49 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 8f8deb9692..e97bb25b9f 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 <tt>BacktraceCleaner#remove_silencers!</tt>, 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 <tt>BacktraceCleaner#remove_silencers!</tt>, 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 @@ module ActiveSupport @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: diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 707544e594..4169557286 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -1,4 +1,4 @@ -require 'test/unit/testcase' +require 'minitest/spec' require 'active_support/testing/setup_and_teardown' require 'active_support/testing/assertions' require 'active_support/testing/deprecation' @@ -9,7 +9,19 @@ require 'active_support/testing/mochaing' require 'active_support/core_ext/kernel/reporting' module ActiveSupport - class TestCase < ::Test::Unit::TestCase + class TestCase < ::MiniTest::Spec + + if MiniTest::Unit::VERSION < '2.6.1' + class << self + alias :name :to_s + end + end + + # Use AS::TestCase for the base class when describing a model + register_spec_type(self) do |desc| + desc < ActiveRecord::Model + end + Assertion = MiniTest::Assertion alias_method :method_name, :name if method_defined? :name alias_method :method_name, :__name__ if method_defined? :__name__ @@ -19,10 +31,27 @@ module ActiveSupport yield if $tags[tag] end + # FIXME: we have tests that depend on run order, we should fix that and + # remove this method. + def self.test_order # :nodoc: + :sorted + end + include ActiveSupport::Testing::SetupAndTeardown include ActiveSupport::Testing::Assertions include ActiveSupport::Testing::Deprecation include ActiveSupport::Testing::Pending extend ActiveSupport::Testing::Declarative + + # test/unit backwards compatibility methods + alias :assert_raise :assert_raises + alias :assert_not_nil :refute_nil + alias :assert_not_equal :refute_equal + alias :assert_no_match :refute_match + alias :assert_not_same :refute_same + + def assert_nothing_raised(*args) + yield + end end end diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 504ac3e9b9..40e25ce0cd 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -18,7 +18,7 @@ silence_warnings do Encoding.default_external = "UTF-8" end -require 'test/unit' +require 'minitest/autorun' require 'empty_bool' silence_warnings { require 'mocha' } @@ -37,4 +37,4 @@ def uses_memcached(test_name) end # Show backtraces for deprecated behavior for quicker cleanup. -ActiveSupport::Deprecation.debug = true
\ No newline at end of file +ActiveSupport::Deprecation.debug = true diff --git a/activesupport/test/test_case_test.rb b/activesupport/test/test_case_test.rb index 20982d089d..e5b5547478 100644 --- a/activesupport/test/test_case_test.rb +++ b/activesupport/test/test_case_test.rb @@ -20,6 +20,10 @@ module ActiveSupport def test_callback_with_exception tc = Class.new(TestCase) do + def self.name + nil + end + setup :bad_callback def bad_callback; raise 'oh noes' end def test_true; assert true end @@ -39,6 +43,10 @@ module ActiveSupport def test_teardown_callback_with_exception tc = Class.new(TestCase) do + def self.name + nil + end + teardown :bad_callback def bad_callback; raise 'oh noes' end def test_true; assert true end diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb index e371238101..1d96c20bb6 100644 --- a/activesupport/test/ts_isolated.rb +++ b/activesupport/test/ts_isolated.rb @@ -1,6 +1,6 @@ $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib') -require 'test/unit' +require 'minitest/autorun' require 'active_support/test_case' require 'rbconfig' require 'active_support/core_ext/kernel/reporting' |