From f27f7e4370331108a19bd542e6c6cd3e3f647865 Mon Sep 17 00:00:00 2001 From: nick evans Date: Sat, 7 Jan 2023 10:01:46 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Warn=20about=20deprecated=20resp?= =?UTF-8?q?onses=20usage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/net/imap.rb | 2 +- test/net/imap/test_imap.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 52e130b6..9a6940ef 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -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 diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index 0078956d..86745957 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -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