Skip to content

Commit 1c3f43c

Browse files
committed
🔊 Update #responses deprecation message
The same message is used for both the warning and the ArgumentError.
1 parent 37daa7f commit 1c3f43c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/net/imap.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,12 @@ def idle_done
24902490
end
24912491
end
24922492

2493+
RESPONSES_DEPRECATION_MSG =
2494+
"Pass a type or block to #responses, " \
2495+
"set config.responses_without_block to :silence_deprecation_warning, " \
2496+
"or use #extract_responses or #clear_responses."
2497+
private_constant :RESPONSES_DEPRECATION_MSG
2498+
24932499
# :call-seq:
24942500
# responses {|hash| ...} -> block result
24952501
# responses(type) {|array| ...} -> block result
@@ -2584,10 +2590,9 @@ def responses(type = nil)
25842590
else
25852591
case config.responses_without_block
25862592
when :raise
2587-
raise ArgumentError, "Pass a block or use #clear_responses"
2593+
raise ArgumentError, RESPONSES_DEPRECATION_MSG
25882594
when :warn
2589-
warn("DEPRECATED: pass a block or use #clear_responses",
2590-
uplevel: 1, category: :deprecated)
2595+
warn(RESPONSES_DEPRECATION_MSG, uplevel: 1, category: :deprecated)
25912596
end
25922597
@responses
25932598
end

test/net/imap/test_imap_responses.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ def for_each_config_option(imap)
9999
end
100100

101101
def assert_responses_warn
102-
assert_warn(/Pass a block.*or.*clear_responses/i) do
102+
assert_warn(
103+
/
104+
(?=(?-x)Pass a type or block to #responses\b)
105+
(?=.*config\.responses_without_block.*:silence_deprecation_warning\b)
106+
(?=.*\#extract_responses\b)
107+
.*\#clear_responses\b
108+
/ix
109+
) do
103110
yield
104111
end
105112
end

0 commit comments

Comments
 (0)