shard-ameba/spec/ameba/rule/style/predicate_name_spec.cr
2022-12-21 21:13:22 +01:00

40 lines
832 B
Crystal

require "../../../spec_helper"
module Ameba::Rule::Style
subject = PredicateName.new
describe PredicateName do
it "passes if predicate name is correct" do
expect_no_issues subject, <<-CRYSTAL
def valid?(x)
end
class Image
def picture?(x)
end
end
def allow_this_picture?
end
CRYSTAL
end
it "fails if predicate name is wrong" do
expect_issue subject, <<-CRYSTAL
def is_valid?(x)
# ^^^^^^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?'
end
CRYSTAL
end
it "ignores if alternative name isn't valid syntax" do
expect_no_issues subject, <<-CRYSTAL
class Image
def is_404?(x)
true
end
end
CRYSTAL
end
end
end