mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Add Excluded property to the rule
This commit is contained in:
parent
a1854c0aa3
commit
8bf5066d6a
8 changed files with 92 additions and 23 deletions
|
@ -1,43 +1,54 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
module Ameba
|
||||
private def create_todo(formatter)
|
||||
s = Source.new "a = 1"
|
||||
private def create_todo
|
||||
file = IO::Memory.new
|
||||
formatter = Formatter::TODOFormatter.new IO::Memory.new, file
|
||||
|
||||
s = Source.new "a = 1", "source.cr"
|
||||
s.error DummyRule.new, s.location(1, 2), "message"
|
||||
|
||||
formatter.finished [s]
|
||||
file.to_s
|
||||
end
|
||||
|
||||
describe Formatter::TODOFormatter do
|
||||
file = IO::Memory.new
|
||||
subject = Formatter::TODOFormatter.new IO::Memory.new, file
|
||||
|
||||
context "problems not reported" do
|
||||
context "problems not found" do
|
||||
it "does not create todo" do
|
||||
subject.finished [Source.new ""]
|
||||
file = IO::Memory.new
|
||||
formatter = Formatter::TODOFormatter.new IO::Memory.new, file
|
||||
formatter.finished [Source.new ""]
|
||||
file.to_s.empty?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "problems reported" do
|
||||
it "creates a todo with header" do
|
||||
create_todo subject
|
||||
file.to_s.should contain "# This configuration file was generated by"
|
||||
file.to_s.should contain "Ameba version #{VERSION}"
|
||||
context "problems found" do
|
||||
it "creates a valid YAML document" do
|
||||
YAML.parse(create_todo).should_not be_nil
|
||||
end
|
||||
|
||||
it "creates a todo with rule name" do
|
||||
create_todo subject
|
||||
file.to_s.should contain "DummyRule"
|
||||
it "creates a todo with header" do
|
||||
create_todo.should contain "# This configuration file was generated by"
|
||||
end
|
||||
|
||||
it "creates a todo with version" do
|
||||
create_todo.should contain "Ameba version #{VERSION}"
|
||||
end
|
||||
|
||||
it "creates a todo with a rule name" do
|
||||
create_todo.should contain "DummyRule"
|
||||
end
|
||||
|
||||
it "creates a todo with problems count" do
|
||||
create_todo subject
|
||||
file.to_s.should contain "Problems found: 1"
|
||||
create_todo.should contain "Problems found: 1"
|
||||
end
|
||||
|
||||
it "creates a valid YAML document" do
|
||||
create_todo subject
|
||||
YAML.parse(file.to_s).should_not be_nil
|
||||
it "creates a todo with run details" do
|
||||
create_todo.should contain "Run `ameba --only #{DummyRule.class_name}`"
|
||||
end
|
||||
|
||||
it "excludes source from this rule" do
|
||||
create_todo.should contain "Excluded:\n - source.cr"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue