2018-04-05 22:22:46 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-09-29 20:50:43 -04:00
|
|
|
require_relative "../abstract_unit"
|
2018-04-05 22:22:46 -04:00
|
|
|
|
|
|
|
module OtherAfterTeardown
|
|
|
|
def after_teardown
|
2018-04-26 14:38:02 -04:00
|
|
|
super
|
|
|
|
|
2018-04-05 22:22:46 -04:00
|
|
|
@witness = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-26 14:38:02 -04:00
|
|
|
class AfterTeardownTest < ActiveSupport::TestCase
|
2018-04-05 22:22:46 -04:00
|
|
|
include OtherAfterTeardown
|
|
|
|
|
|
|
|
attr_writer :witness
|
|
|
|
|
|
|
|
MyError = Class.new(StandardError)
|
|
|
|
|
|
|
|
teardown do
|
|
|
|
raise MyError, "Test raises an error, all after_teardown should still get called"
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_teardown
|
2018-04-26 14:38:02 -04:00
|
|
|
assert_changes -> { failures.count }, from: 0, to: 1 do
|
2018-04-05 22:22:46 -04:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal true, @witness
|
2018-04-26 14:38:02 -04:00
|
|
|
failures.clear
|
2018-04-05 22:22:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_teardown_raise_but_all_after_teardown_method_are_called
|
|
|
|
assert true
|
|
|
|
end
|
|
|
|
end
|