Skip to content

Commit e74a9f9

Browse files
committed
make collect_deprecations available.
There are circumstances where the capabilities of `assert_deprecated` and `assert_not_deprecated` are not enough. For example if a ccertain call-path raises two deprecations but should only raise a single one. This module is still :nodoc and intented for internal use. /cc @rafaelfranca
1 parent 8211535 commit e74a9f9

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

activesupport/lib/active_support/testing/deprecation.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ def assert_not_deprecated(&block)
1919
result
2020
end
2121

22-
private
23-
def collect_deprecations
24-
old_behavior = ActiveSupport::Deprecation.behavior
25-
deprecations = []
26-
ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
27-
deprecations << message
28-
end
29-
result = yield
30-
[result, deprecations]
31-
ensure
32-
ActiveSupport::Deprecation.behavior = old_behavior
22+
def collect_deprecations
23+
old_behavior = ActiveSupport::Deprecation.behavior
24+
deprecations = []
25+
ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
26+
deprecations << message
3327
end
28+
result = yield
29+
[result, deprecations]
30+
ensure
31+
ActiveSupport::Deprecation.behavior = old_behavior
32+
end
3433
end
3534
end
3635
end

0 commit comments

Comments
 (0)