Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Notified the user when no misspellings were found

  • Loading branch information...
commit ffa36c753d0241a0321c404e35566f6403a40a0f 1 parent a4b2790
@drbrain drbrain authored
View
6 lib/rdoc/generator/spellcheck.rb
@@ -81,12 +81,16 @@ def find_misspelled comment
# Creates the spelling report
def generate files
+ misspellings = 0
+
RDoc::TopLevel.all_classes_and_modules.each do |mod|
mod.comment_location.each do |comment, location|
misspelled = find_misspelled comment
next if misspelled.empty?
+ misspellings += misspelled.length
+
puts "#{mod.definition} in #{location.full_name}:"
puts
misspelled.each do |word, offset|
@@ -94,6 +98,8 @@ def generate files
end
end
end
+
+ puts 'No misspellings found' if misspellings.zero?
end
def suggestion_text text, word, offset
View
14 test/test_rdoc_generator_spellcheck.rb
@@ -70,6 +70,20 @@ def test_generate
assert_match %r%^"gud"%, out
end
+ def test_generate_correct
+ klass = @top_level.add_class RDoc::NormalClass, 'Object'
+
+ c = comment 'This class has perfect spelling!'
+ klass.add_comment c, @top_level
+
+ out, err = capture_io do
+ @sc.generate [@top_level]
+ end
+
+ assert_empty err
+ assert_equal "No misspellings found\n", out
+ end
+
def test_suggestion_text
out = @sc.suggestion_text @text, 'gud', 28
Please sign in to comment.
Something went wrong with that request. Please try again.