Method: ActiveSupport::Testing::Deprecation#assert_not_deprecated

Defined in:
activesupport/lib/active_support/testing/deprecation.rb

#assert_not_deprecated(deprecator, &block) ⇒ Object

Asserts that no deprecation warnings are emitted by the given deprecator during the execution of the yielded block.

assert_not_deprecated(CustomDeprecator) do
  CustomDeprecator.warn "message" # fails assertion
end

assert_not_deprecated(ActiveSupport::Deprecation.new) do
  CustomDeprecator.warn "message" # passes assertion, different deprecator
end


55
56
57
58
59
# File 'activesupport/lib/active_support/testing/deprecation.rb', line 55

def assert_not_deprecated(deprecator, &block)
  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