diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-10-28 23:58:12 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-10-29 07:56:32 +0000 |
commit | 21b3dfa03bf613aad303b889dd63ef64bb2ada9b (patch) | |
tree | ac9255dc3aa6a0ef67e5632a966550fb60ed089f | |
parent | 7889b888389b674efa5f46100d7c05abb626777a (diff) |
[ruby/error_highlight] Suppress smaller `max_snippet_width` warning
https://github.com/ruby/error_highlight/commit/9cd14c5b9a
-rw-r--r-- | test/error_highlight/test_error_highlight.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/error_highlight/test_error_highlight.rb b/test/error_highlight/test_error_highlight.rb index a59550b053..09f29dc74d 100644 --- a/test/error_highlight/test_error_highlight.rb +++ b/test/error_highlight/test_error_highlight.rb @@ -1358,8 +1358,18 @@ undefined method `time' for #{ ONE_RECV_MESSAGE } def test_errors_on_terminal_window_smaller_than_min_width custom_max_width = 5 original_max_width = ErrorHighlight::DefaultFormatter.max_snippet_width + min_snippet_width = ErrorHighlight::DefaultFormatter::MIN_SNIPPET_WIDTH - ErrorHighlight::DefaultFormatter.max_snippet_width = custom_max_width + warning = nil + original_warn = Warning.method(:warn) + Warning.define_singleton_method(:warn) {|s| warning = s} + begin + ErrorHighlight::DefaultFormatter.max_snippet_width = custom_max_width + ensure + Warning.singleton_class.remove_method(:warn) + Warning.define_singleton_method(:warn, original_warn) + end + assert_match "'max_snippet_width' adjusted to minimum value of #{min_snippet_width}", warning assert_error_message(NoMethodError, <<~END) do undefined method `time' for #{ ONE_RECV_MESSAGE } |