module ActiveSupport::Testing::Deprecation

def collect_deprecations(deprecator = nil)

end # => ["message"]
ActiveSupport::Deprecation.warn "message"
CustomDeprecator.warn "custom message"
collect_deprecations do

If no +deprecator+ is given, defaults to ActiveSupport::Deprecation.

end # => ["message"]
CustomDeprecator.warn "message"
collect_deprecations(CustomDeprecator) do

+deprecator+ during the execution of the yielded block.
Returns an array of all the deprecation warnings emitted by the given
def collect_deprecations(deprecator = nil)
  deprecator ||= ActiveSupport::Deprecation
  old_behavior = deprecator.behavior
  deprecations = []
  deprecator.behavior = Proc.new do |message, callstack|
    deprecations << message
  end
  result = yield
  [result, deprecations]
ensure
  deprecator.behavior = old_behavior
end