Skip to content

assert_deprecated_warning: restore Warning[:deprecated] #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/core_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -647,17 +647,15 @@ def assert_warn(*args)
assert_warning(*args) {$VERBOSE = false; yield}
end

def assert_deprecated_warning(mesg = /deprecated/)
def assert_deprecated_warning(mesg = /deprecated/, &block)
assert_warning(mesg) do
Warning[:deprecated] = true if Warning.respond_to?(:[]=)
yield
EnvUtil.deprecation_warning(&block)
end
end

def assert_deprecated_warn(mesg = /deprecated/)
assert_warn(mesg) do
Warning[:deprecated] = true if Warning.respond_to?(:[]=)
yield
EnvUtil.deprecation_warning(&block)
end
end

Expand Down
15 changes: 15 additions & 0 deletions lib/envutil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,21 @@ def flush; end
end
module_function :verbose_warning

if defined?(Warning.[]=)
def deprecation_warning
previous_deprecated = Warning[:deprecated]
Warning[:deprecated] = true
yield
ensure
Warning[:deprecated] = previous_deprecated
end
else
def deprecation_warning
yield
end
end
module_function :deprecation_warning

def default_warning
$VERBOSE = false
yield
Expand Down