File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
13651375undefined method `time' for #{ ONE_RECV_MESSAGE }
You can’t perform that action at this time.
0 commit comments