diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/test_case.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/testing/setup_and_teardown.rb | 14 | ||||
-rw-r--r-- | activesupport/test/testing/after_teardown_test.rb | 8 |
3 files changed, 11 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 4e42db4500..f17743b6db 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -130,7 +130,7 @@ module ActiveSupport alias_method :method_name, :name include ActiveSupport::Testing::TaggedLogging - include ActiveSupport::Testing::SetupAndTeardown + prepend ActiveSupport::Testing::SetupAndTeardown include ActiveSupport::Testing::Assertions include ActiveSupport::Testing::Deprecation include ActiveSupport::Testing::TimeHelpers diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb index 35236f1401..35321cd157 100644 --- a/activesupport/lib/active_support/testing/setup_and_teardown.rb +++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require "active_support/concern" require "active_support/callbacks" module ActiveSupport @@ -19,11 +18,10 @@ module ActiveSupport # end # end module SetupAndTeardown - extend ActiveSupport::Concern - - included do - include ActiveSupport::Callbacks - define_callbacks :setup, :teardown + def self.prepended(klass) + klass.include ActiveSupport::Callbacks + klass.define_callbacks :setup, :teardown + klass.extend ClassMethods end module ClassMethods @@ -47,12 +45,10 @@ module ActiveSupport begin run_callbacks :teardown rescue => e - error = e + self.failures << Minitest::UnexpectedError.new(e) end super - ensure - raise error if error end end end diff --git a/activesupport/test/testing/after_teardown_test.rb b/activesupport/test/testing/after_teardown_test.rb index 68c368909c..961af49479 100644 --- a/activesupport/test/testing/after_teardown_test.rb +++ b/activesupport/test/testing/after_teardown_test.rb @@ -4,13 +4,14 @@ require "abstract_unit" module OtherAfterTeardown def after_teardown + super + @witness = true end end -class AfterTeardownTest < Minitest::Test +class AfterTeardownTest < ActiveSupport::TestCase include OtherAfterTeardown - include ActiveSupport::Testing::SetupAndTeardown attr_writer :witness @@ -21,11 +22,12 @@ class AfterTeardownTest < Minitest::Test end def after_teardown - assert_raises MyError do + assert_changes -> { failures.count }, from: 0, to: 1 do super end assert_equal true, @witness + failures.clear end def test_teardown_raise_but_all_after_teardown_method_are_called |