diff options
author | Yuki Nishijima <yk.nishijima@gmail.com> | 2021-10-22 20:56:26 -0400 |
---|---|---|
committer | Yuki Nishijima <yk.nishijima@gmail.com> | 2021-10-22 20:56:26 -0400 |
commit | 22249bbb371d794c0330c1a4512f2581c1040297 (patch) | |
tree | 7d22c2dfc085e9dd3f478f9cd3ca312be345a308 /test | |
parent | e22d293e06966733e71a7fd9725eee06c03d0177 (diff) |
Revert "Sync did_you_mean"
This reverts commit e22d293e06966733e71a7fd9725eee06c03d0177.
Diffstat (limited to 'test')
-rw-r--r-- | test/did_you_mean/spell_checking/test_pattern_key_name_check.rb | 20 | ||||
-rw-r--r-- | test/did_you_mean/test_spell_checker.rb | 1 | ||||
-rw-r--r-- | test/did_you_mean/test_verbose_formatter.rb | 38 |
3 files changed, 38 insertions, 21 deletions
diff --git a/test/did_you_mean/spell_checking/test_pattern_key_name_check.rb b/test/did_you_mean/spell_checking/test_pattern_key_name_check.rb deleted file mode 100644 index 2b0752a56a..0000000000 --- a/test/did_you_mean/spell_checking/test_pattern_key_name_check.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative '../helper' - -return if !defined?(::NoMatchingPatternKeyError) - -class PatternKeyNameCheckTest < Test::Unit::TestCase - include DidYouMean::TestHelper - - def test_corrects_hash_key_name_with_single_pattern_match - error = assert_raise(NoMatchingPatternKeyError) do - eval(<<~RUBY, binding, __FILE__, __LINE__) - hash = {foo: 1, bar: 2, baz: 3} - hash => {fooo:} - fooo = 1 # suppress "unused variable: fooo" warning - RUBY - end - - assert_correction ":foo", error.corrections - assert_match "Did you mean? :foo", error.to_s - end -end diff --git a/test/did_you_mean/test_spell_checker.rb b/test/did_you_mean/test_spell_checker.rb index 8445380de3..98460b4d94 100644 --- a/test/did_you_mean/test_spell_checker.rb +++ b/test/did_you_mean/test_spell_checker.rb @@ -10,7 +10,6 @@ class SpellCheckerTest < Test::Unit::TestCase assert_spell 'eval', input: 'veal', dictionary: ['email', 'fail', 'eval'] assert_spell 'sub!', input: 'suv!', dictionary: ['sub', 'gsub', 'sub!'] assert_spell 'sub', input: 'suv', dictionary: ['sub', 'gsub', 'sub!'] - assert_spell 'Foo', input: 'FOo', dictionary: ['Foo', 'FOo'] assert_spell %w(gsub! gsub), input: 'gsuv!', dictionary: %w(sub gsub gsub!) assert_spell %w(sub! sub gsub!), input: 'ssub!', dictionary: %w(sub sub! gsub gsub!) diff --git a/test/did_you_mean/test_verbose_formatter.rb b/test/did_you_mean/test_verbose_formatter.rb new file mode 100644 index 0000000000..411f175180 --- /dev/null +++ b/test/did_you_mean/test_verbose_formatter.rb @@ -0,0 +1,38 @@ +require_relative './helper' + +class VerboseFormatterTest < Test::Unit::TestCase + class ErrorHighlightDummyFormatter + def message_for(spot) + "" + end + end + + def setup + require_relative File.join(DidYouMean::TestHelper.root, 'verbose') + + DidYouMean.formatter = DidYouMean::VerboseFormatter.new + + if defined?(ErrorHighlight) + @error_highlight_old_formatter = ErrorHighlight.formatter + ErrorHighlight.formatter = ErrorHighlightDummyFormatter.new + end + end + + def teardown + DidYouMean.formatter = DidYouMean::PlainFormatter.new + + if defined?(ErrorHighlight) + ErrorHighlight.formatter = @error_highlight_old_formatter + end + end + + def test_message + @error = assert_raise(NoMethodError){ 1.zeor? } + + assert_match <<~MESSAGE.strip, @error.message + undefined method `zeor?' for 1:Integer + + Did you mean? zero? + MESSAGE + end +end |