Use issue expectation helpers in Layout::LineLength rule spec

This commit is contained in:
Sijawusz Pur Rahnama 2022-04-04 22:15:07 +02:00
parent 390b26d7f1
commit 8a37d5bbe2

View file

@ -6,13 +6,15 @@ module Ameba::Rule::Layout
describe LineLength do
it "passes if all lines are shorter than MaxLength symbols" do
source = Source.new "short line"
subject.catch(source).should be_valid
expect_no_issues subject, <<-CRYSTAL
short line
CRYSTAL
end
it "passes if line consists of MaxLength symbols" do
source = Source.new "*" * subject.max_length
subject.catch(source).should be_valid
expect_no_issues subject, <<-CRYSTAL
#{"*" * subject.max_length}
CRYSTAL
end
it "fails if there is at least one line longer than MaxLength symbols" do
@ -33,10 +35,10 @@ module Ameba::Rule::Layout
context "properties" do
it "allows to configure max length of the line" do
source = Source.new long_line
rule = LineLength.new
rule.max_length = long_line.size
rule.catch(source).should be_valid
expect_no_issues rule, long_line
end
end
end