Skip to content

Commit 9cd14c5

Browse files
nobumame
authored andcommitted
Suppress smaller max_snippet_width warning
1 parent e13cbd4 commit 9cd14c5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/test_error_highlight.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,18 @@ def test_errors_on_extremely_small_terminal_window
13581358
def test_errors_on_terminal_window_smaller_than_min_width
13591359
custom_max_width = 5
13601360
original_max_width = ErrorHighlight::DefaultFormatter.max_snippet_width
1361+
min_snippet_width = ErrorHighlight::DefaultFormatter::MIN_SNIPPET_WIDTH
13611362

1362-
ErrorHighlight::DefaultFormatter.max_snippet_width = custom_max_width
1363+
warning = nil
1364+
original_warn = Warning.method(:warn)
1365+
Warning.define_singleton_method(:warn) {|s| warning = s}
1366+
begin
1367+
ErrorHighlight::DefaultFormatter.max_snippet_width = custom_max_width
1368+
ensure
1369+
Warning.singleton_class.remove_method(:warn)
1370+
Warning.define_singleton_method(:warn, original_warn)
1371+
end
1372+
assert_match "'max_snippet_width' adjusted to minimum value of #{min_snippet_width}", warning
13631373

13641374
assert_error_message(NoMethodError, <<~END) do
13651375
undefined method `time' for #{ ONE_RECV_MESSAGE }

0 commit comments

Comments
 (0)