Method: ActiveSupport::Testing::Deprecation#collect_deprecations
- Defined in:
- activesupport/lib/active_support/testing/deprecation.rb
#collect_deprecations(deprecator) ⇒ Object
Returns the return value of the block and an array of all the deprecation warnings emitted by the given deprecator during the execution of the yielded block.
collect_deprecations(CustomDeprecator) do
CustomDeprecator.warn "message"
ActiveSupport::Deprecation.new.warn "other message"
:result
end # => [:result, ["message"]]
69 70 71 72 73 74 75 76 77 78 79 |
# File 'activesupport/lib/active_support/testing/deprecation.rb', line 69 def collect_deprecations(deprecator) old_behavior = deprecator.behavior deprecations = [] deprecator.behavior = Proc.new do |, callstack| deprecations << end result = yield [result, deprecations] ensure deprecator.behavior = old_behavior end |