2019-10-29 10:08:37 -04:00
|
|
|
require_relative './helper'
|
|
|
|
|
|
|
|
class VerboseFormatterTest < Test::Unit::TestCase
|
2021-08-16 21:52:10 -04:00
|
|
|
class ErrorHighlightDummyFormatter
|
|
|
|
def message_for(spot)
|
|
|
|
""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-29 10:08:37 -04:00
|
|
|
def setup
|
|
|
|
require_relative File.join(DidYouMean::TestHelper.root, 'verbose')
|
2020-05-22 17:17:10 -04:00
|
|
|
|
2020-02-09 04:34:47 -05:00
|
|
|
DidYouMean.formatter = DidYouMean::VerboseFormatter.new
|
2021-08-16 21:52:10 -04:00
|
|
|
|
|
|
|
if defined?(ErrorHighlight)
|
|
|
|
@error_highlight_old_formatter = ErrorHighlight.formatter
|
|
|
|
ErrorHighlight.formatter = ErrorHighlightDummyFormatter.new
|
|
|
|
end
|
2019-10-29 10:08:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
DidYouMean.formatter = DidYouMean::PlainFormatter.new
|
2021-08-16 21:52:10 -04:00
|
|
|
|
|
|
|
if defined?(ErrorHighlight)
|
|
|
|
ErrorHighlight.formatter = @error_highlight_old_formatter
|
|
|
|
end
|
2019-10-29 10:08:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_message
|
|
|
|
@error = assert_raise(NoMethodError){ 1.zeor? }
|
|
|
|
|
2019-11-30 22:29:02 -05:00
|
|
|
assert_match <<~MESSAGE.strip, @error.message
|
2019-10-29 10:08:37 -04:00
|
|
|
undefined method `zeor?' for 1:Integer
|
|
|
|
|
|
|
|
Did you mean? zero?
|
|
|
|
MESSAGE
|
|
|
|
end
|
|
|
|
end
|