Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress smaller max_snippet_width warning #53

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion test/test_error_highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,18 @@ def test_errors_on_extremely_small_terminal_window
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 }
Expand Down