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 describe LineLength do
it "passes if all lines are shorter than MaxLength symbols" do it "passes if all lines are shorter than MaxLength symbols" do
source = Source.new "short line" expect_no_issues subject, <<-CRYSTAL
subject.catch(source).should be_valid short line
CRYSTAL
end end
it "passes if line consists of MaxLength symbols" do it "passes if line consists of MaxLength symbols" do
source = Source.new "*" * subject.max_length expect_no_issues subject, <<-CRYSTAL
subject.catch(source).should be_valid #{"*" * subject.max_length}
CRYSTAL
end end
it "fails if there is at least one line longer than MaxLength symbols" do 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 context "properties" do
it "allows to configure max length of the line" do it "allows to configure max length of the line" do
source = Source.new long_line
rule = LineLength.new rule = LineLength.new
rule.max_length = long_line.size rule.max_length = long_line.size
rule.catch(source).should be_valid
expect_no_issues rule, long_line
end end
end end
end end