Skip to content

Commit e033904

Browse files
committed
Added test for #180
When loading a class or module from the RDoc store then reparsing its source file the old comment is replaced with the new comment. This also means that if a module or class is mentioned multiple times in the same file RDoc will only use the last comment. These two behaviors of the comment conflict, so I must delay fixing this issue until the future while I think about it.
1 parent 94e189b commit e033904

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/test_rdoc_parser_ruby.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,30 @@ module M
27802780
assert c.documented?
27812781
end
27822782

2783+
def test_scan_duplicate_module
2784+
content = <<-CONTENT
2785+
# comment a
2786+
module Foo
2787+
end
2788+
2789+
# comment b
2790+
module Foo
2791+
end
2792+
CONTENT
2793+
2794+
util_parser content
2795+
2796+
@parser.scan
2797+
2798+
foo = @top_level.modules.first
2799+
2800+
expected = [
2801+
RDoc::Comment.new('comment b', @top_level)
2802+
]
2803+
2804+
assert_equal expected, foo.comment_location.map { |c, l| c }
2805+
end
2806+
27832807
def test_scan_meta_method_block
27842808
content = <<-CONTENT
27852809
class C

0 commit comments

Comments
 (0)