Permalink
Browse files

Improved handling of single quotes in and around words

  • Loading branch information...
1 parent d7c21cf commit 858ae92f282df52d15805dbddf765ce63ba9e8ad @drbrain drbrain committed Apr 6, 2012
Showing with 25 additions and 2 deletions.
  1. +5 −2 lib/rdoc/generator/spellcheck.rb
  2. +20 −0 test/test_rdoc_generator_spellcheck.rb
@@ -156,10 +156,13 @@ def add_name name
def find_misspelled comment
report = []
- comment.text.scan(/[a-z]+/i) do |word|
+ comment.text.scan(/[a-z][a-z']+[a-z]/i) do |word|
+ offset = $`.length # store
+
+ word = $` if word =~ /'s$/i
+
next if @spell.check word
- offset = $`.length
offset = offset.zero? ? 0 : offset + 1
report << [word, offset]
@@ -141,6 +141,26 @@ def test_find_misspelled
assert_equal 28, offset
end
+ def test_find_misspelled_quote
+ c = comment "doesn't"
+
+ report = @sc.find_misspelled c
+
+ assert_empty report
+
+ c = comment "'quoted'"
+
+ report = @sc.find_misspelled c
+
+ assert_empty report
+
+ c = comment "other's"
+
+ report = @sc.find_misspelled c
+
+ assert_empty report
+ end
+
def test_find_misspelled_underscore
c = comment 'gud_method'

0 comments on commit 858ae92

Please sign in to comment.