2020-04-06 12:10:34 +00:00
|
|
|
require "../../../spec_helper"
|
|
|
|
|
|
|
|
module Ameba::Rule::Lint
|
|
|
|
describe BadDirective do
|
|
|
|
subject = BadDirective.new
|
|
|
|
|
|
|
|
it "does not report if rule is correct" do
|
2022-04-04 19:27:04 +00:00
|
|
|
expect_no_issues subject, <<-CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
# ameba:disable Lint/BadDirective
|
2022-04-04 19:27:04 +00:00
|
|
|
CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "reports if there is incorrect action" do
|
2022-04-04 19:27:04 +00:00
|
|
|
expect_issue subject, <<-CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
# ameba:foo Lint/BadDirective
|
2022-04-04 19:27:04 +00:00
|
|
|
# ^{} error: Bad action in comment directive: 'foo'. Possible values: disable, enable
|
|
|
|
CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "reports if there are incorrect rule names" do
|
2022-04-04 19:27:04 +00:00
|
|
|
expect_issue subject, <<-CRYSTAL
|
2020-04-11 06:55:41 +00:00
|
|
|
# ameba:enable BadRule1, BadRule2
|
2022-04-04 19:27:04 +00:00
|
|
|
# ^{} error: Such rules do not exist: BadRule1, BadRule2
|
|
|
|
CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not report if there no action and rules at all" do
|
2022-04-04 19:27:04 +00:00
|
|
|
expect_no_issues subject, <<-CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
# ameba:
|
2022-04-04 19:27:04 +00:00
|
|
|
CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not report if there are no rules" do
|
2022-04-04 19:27:04 +00:00
|
|
|
expect_no_issues subject, <<-CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
# ameba:enable
|
|
|
|
# ameba:disable
|
2022-04-04 19:27:04 +00:00
|
|
|
CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not report if there are group names in the directive" do
|
2022-04-04 19:27:04 +00:00
|
|
|
expect_no_issues subject, <<-CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
# ameba:disable Style Performance
|
2022-04-04 19:27:04 +00:00
|
|
|
CRYSTAL
|
2020-04-06 12:10:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|