Autocorrect various rules (#253)

This commit is contained in:
fn ⌃ ⌥ 2021-11-16 13:30:33 -08:00 committed by GitHub
parent 255d10f921
commit 63a6c73dc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 676 additions and 175 deletions

View file

@ -5,13 +5,15 @@ module Ameba::Rule::Layout
describe TrailingWhitespace do
it "passes if all lines do not have trailing whitespace" do
source = Source.new "no-whispace"
subject.catch(source).should be_valid
expect_no_issues subject, "no-whispace"
end
it "fails if there is a line with trailing whitespace" do
source = Source.new "whitespace at the end "
subject.catch(source).should_not be_valid
source = expect_issue subject,
"whitespace at the end \n" \
" # ^^ error: Trailing whitespace detected"
expect_correction source, "whitespace at the end"
end
it "reports rule, pos and message" do
@ -21,7 +23,7 @@ module Ameba::Rule::Layout
issue = source.issues.first
issue.rule.should_not be_nil
issue.location.to_s.should eq "source.cr:2:7"
issue.end_location.should be_nil
issue.end_location.to_s.should eq "source.cr:2:7"
issue.message.should eq "Trailing whitespace detected"
end
end