Fix code to support older versions of Ruby

We still support super old versions, yes, and it doesn't like `ensure`
without a `begin..end` unfortunately.

I plan to remove this support soon, but for now I don't want to stop
supporting it yet.
This commit is contained in:
Carlos Antonio da Silva
2023-09-12 21:52:54 -03:00
parent 9784555304
commit fb7faf7466

View File

@@ -27,11 +27,14 @@ class ActiveSupport::TestCase
if ActiveSupport.version < Gem::Version.new("5.0")
def assert_deprecated(match, deprecator)
super(match) do
behavior = deprecator.behavior
deprecator.behavior = ActiveSupport::Deprecation.behavior
yield
ensure
deprecator.behavior = behavior
# TODO: remove extra begin..end when dropping support for Ruby <= 2.4
begin
behavior = deprecator.behavior
deprecator.behavior = ActiveSupport::Deprecation.behavior
yield
ensure
deprecator.behavior = behavior
end
end
end
end