Skip to content

Commit

Permalink
🔊 Warn about deprecated responses usage
Browse files Browse the repository at this point in the history
This was extracted from #93 and split into a separate PR.

This allows us to prepare dependent projects for the new behavior before
their logs are flooded with deprecation warnings.
  • Loading branch information
nevans committed May 19, 2024
1 parent 60b46e0 commit f27f7e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ def responses(type = nil)
elsif type
raise ArgumentError, "Pass a block or use #clear_responses"
else
# warn("DEPRECATED: pass a block or use #clear_responses", uplevel: 1)
warn("DEPRECATED: pass a block or use #clear_responses", uplevel: 1)
@responses
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,10 @@ def test_responses
assert_equal(1, imap.responses("RECENT", &:last))
assert_raise(ArgumentError) do imap.responses("UIDNEXT") end
# Deprecated style, without a block:
# assert_warn(/Pass a block.*or.*clear_responses/i) do
# assert_equal(%i[Answered Flagged Deleted Seen Draft],
# imap.responses["FLAGS"]&.last)
# end
assert_warn(/Pass a block.*or.*clear_responses/i) do
assert_equal(%i[Answered Flagged Deleted Seen Draft],
imap.responses["FLAGS"]&.last)
end
end
end

Expand Down

0 comments on commit f27f7e4

Please sign in to comment.