instance method assert_not_deprecated

Ruby on Rails 7.1.6

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

assert_not_deprecated(deprecator = nil, &block)

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

Parameters

deprecator opt = nil
block block
Source
# File activesupport/lib/active_support/testing/deprecation.rb, line 54
      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

Defined in activesupport/lib/active_support/testing/deprecation.rb line 54 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Testing::Deprecation

Type at least 2 characters to search.

↑↓ navigate · open · esc close