module ActiveSupport::Testing::Deprecation
def assert_not_deprecated(deprecator = nil, &block)
CustomDeprecator.warn "message" # passes assertion, different deprecator
assert_not_deprecated(ActiveSupport::Deprecation.new) do
end
CustomDeprecator.warn "message" # fails assertion
assert_not_deprecated(CustomDeprecator) do
Asserts that no deprecation warnings are emitted by the given deprecator during the execution of the yielded block.
def assert_not_deprecated(deprecator = nil, &block) unless deprecator ActiveSupport.deprecator.warn("assert_not_deprecated without a deprecator is deprecated") deprecator = ActiveSupport::Deprecation._instance end result, deprecations = collect_deprecations(deprecator, &block) assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n #{deprecations * "\n "}" result end