diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-12-10 15:22:31 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-12-10 15:22:31 +0100 |
commit | e74a9f9eea4fd2dee7fb2e65c95c713d11f4cdcc (patch) | |
tree | 973b86e79b83933a579adf4e15b293c1befaddd2 /activesupport/lib | |
parent | 821153525cefb1a809be06ae584f24f5c0c11323 (diff) | |
download | rails-e74a9f9eea4fd2dee7fb2e65c95c713d11f4cdcc.tar.gz rails-e74a9f9eea4fd2dee7fb2e65c95c713d11f4cdcc.tar.bz2 rails-e74a9f9eea4fd2dee7fb2e65c95c713d11f4cdcc.zip |
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
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/testing/deprecation.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/testing/deprecation.rb b/activesupport/lib/active_support/testing/deprecation.rb index a8342904dc..6c94c611b6 100644 --- a/activesupport/lib/active_support/testing/deprecation.rb +++ b/activesupport/lib/active_support/testing/deprecation.rb @@ -19,18 +19,17 @@ module ActiveSupport result end - private - def collect_deprecations - old_behavior = ActiveSupport::Deprecation.behavior - deprecations = [] - ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack| - deprecations << message - end - result = yield - [result, deprecations] - ensure - ActiveSupport::Deprecation.behavior = old_behavior + def collect_deprecations + old_behavior = ActiveSupport::Deprecation.behavior + deprecations = [] + ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack| + deprecations << message end + result = yield + [result, deprecations] + ensure + ActiveSupport::Deprecation.behavior = old_behavior + end end end end |