Add test spec covering accessor macros

This commit is contained in:
Sijawusz Pur Rahnama 2023-12-28 03:29:09 +01:00
parent 4567293add
commit aeffa6ad00
1 changed files with 17 additions and 0 deletions

View File

@ -393,6 +393,23 @@ module Ameba::Rule::Lint
CRYSTAL CRYSTAL
end end
it "doesn't report if this is an accessor declaration" do
accessor_macros = %w[setter class_setter]
%w[getter class_getter property class_property].each do |name|
accessor_macros << name
accessor_macros << "#{name}?"
accessor_macros << "#{name}!"
end
accessor_macros.each do |accessor|
expect_no_issues subject, <<-CRYSTAL
class Foo
#{accessor} foo : String?
#{accessor} bar = "bar"
end
CRYSTAL
end
end
it "does not report if assignment is referenced after the record declaration" do it "does not report if assignment is referenced after the record declaration" do
expect_no_issues subject, <<-CRYSTAL expect_no_issues subject, <<-CRYSTAL
foo = 2 foo = 2