mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
33 lines
904 B
Crystal
33 lines
904 B
Crystal
require "../../spec_helper"
|
|
|
|
module Ameba::Rule
|
|
subject = LineLength.new
|
|
long_line = "*" * 81
|
|
|
|
describe LineLength do
|
|
it "passes if all lines are shorter than 80 symbols" do
|
|
source = Source.new "short line"
|
|
subject.catch(source).should be_valid
|
|
end
|
|
|
|
it "passes if line consists of 79 symbols" do
|
|
source = Source.new "*" * 80
|
|
subject.catch(source).should be_valid
|
|
end
|
|
|
|
it "fails if there is at least one line longer than 79 symbols" do
|
|
source = Source.new long_line
|
|
subject.catch(source).should_not be_valid
|
|
end
|
|
|
|
it "reports rule, pos and message" do
|
|
source = Source.new long_line, "source.cr"
|
|
subject.catch(source).should_not be_valid
|
|
|
|
error = source.errors.first
|
|
error.rule.should eq subject
|
|
error.location.to_s.should eq "source.cr:1:81"
|
|
error.message.should eq "Line too long"
|
|
end
|
|
end
|
|
end
|