Avoid duplicated sections in a generated TODO file

This commit is contained in:
Vitalii Elenhaupt 2019-10-27 22:15:04 +02:00
parent 19d9223ec1
commit 111596541b
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
3 changed files with 38 additions and 0 deletions

View file

@ -76,6 +76,30 @@ module Ameba
create_todo.should contain "Excluded:\n - source.cr"
end
context "with multiple issues" do
formatter = Formatter::TODOFormatter.new IO::Memory.new
s1 = Source.new "a = 1", "source1.cr"
s2 = Source.new "a = 1", "source2.cr"
s1.add_issue DummyRule.new, {1, 2}, "message1"
s1.add_issue DummyRule.new, {2, 2}, "message1"
s2.add_issue DummyRule.new, {2, 2}, "message2"
file = formatter.finished([s1, s2])
content = File.read(file.not_nil!.path)
content.should contain <<-CONTENT
# Problems found: 3
# Run `ameba --only Ameba/DummyRule` for details
Ameba/DummyRule:
Description: Dummy rule that does nothing.
Enabled: true
Severity: Convention
Excluded:
- source1.cr
- source2.cr
CONTENT
end
context "when invalid syntax" do
it "does generate todo file" do
formatter = Formatter::TODOFormatter.new IO::Memory.new