mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Add Lint/Formatting
rule
This commit is contained in:
parent
e6ebca7a5b
commit
3bc8bda008
2 changed files with 113 additions and 0 deletions
48
spec/ameba/rule/lint/formatting_spec.cr
Normal file
48
spec/ameba/rule/lint/formatting_spec.cr
Normal file
|
@ -0,0 +1,48 @@
|
|||
require "../../../spec_helper"
|
||||
|
||||
module Ameba::Rule::Lint
|
||||
describe Formatting do
|
||||
subject = Formatting.new
|
||||
|
||||
it "passes if source is formatted" do
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
def method(a, b)
|
||||
a + b
|
||||
end
|
||||
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports if source is not formatted" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
def method(a,b)
|
||||
# ^{} error: Use built-in formatter to format this source
|
||||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
context "properties" do
|
||||
context "#fail_on_error" do
|
||||
it "passes on formatter errors by default" do
|
||||
rule = Formatting.new
|
||||
|
||||
expect_no_issues rule, <<-CRYSTAL
|
||||
def method(a, b)
|
||||
a + b
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports on formatter errors when enabled" do
|
||||
rule = Formatting.new
|
||||
rule.fail_on_error = true
|
||||
|
||||
expect_issue rule, <<-CRYSTAL
|
||||
def method(a, b)
|
||||
a + b
|
||||
# ^ error: Error while formatting: expecting identifier 'end', not 'EOF'
|
||||
CRYSTAL
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue