Sha256: b43c4c2ca4f53ca47f9aea342cd42f0465d936e0e38d8addbab50784f3fe3e11
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require_relative '../helper' class NameErrorExtensionTest < Test::Unit::TestCase SPELL_CHECKERS = DidYouMean.spell_checkers class TestSpellChecker def initialize(*); end def corrections; ["does_exist"]; end end def setup @original_spell_checker = DidYouMean.spell_checkers['NameError'] DidYouMean.correct_error(NameError, TestSpellChecker) @error = assert_raise(NameError){ doesnt_exist } end def teardown DidYouMean.correct_error(NameError, @original_spell_checker) end def test_message assert_match(/Did you mean\? does_exist/, @error.to_s) assert_match(/Did you mean\? does_exist/, @error.message) end def test_to_s_does_not_make_disruptive_changes_to_error_message error = assert_raise(NameError) do raise NameError, "uninitialized constant Object" end error.to_s assert_equal 1, error.to_s.scan("Did you mean?").count end def test_correctable_error_objects_are_dumpable error = begin Dir.chdir(__dir__) { File.open('test_name_error_extension.rb') { |f| f.sizee } } rescue NoMethodError => e e end error.to_s assert_equal "undefined method `sizee' for #<File:test_name_error_extension.rb (closed)>", Marshal.load(Marshal.dump(error)).original_message end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
did_you_mean-1.6.1 | test/core_ext/test_name_error_extension.rb |