shard-ameba/spec/ameba/rule/style/predicate_name_spec.cr

41 lines
832 B
Crystal
Raw Normal View History

require "../../../spec_helper"
2017-11-01 13:20:04 +00:00
module Ameba::Rule::Style
2017-11-01 13:20:04 +00:00
subject = PredicateName.new
describe PredicateName do
it "passes if predicate name is correct" do
2021-10-27 22:58:58 +00:00
expect_no_issues subject, <<-CRYSTAL
2017-11-01 13:20:04 +00:00
def valid?(x)
end
class Image
def picture?(x)
end
end
2017-11-23 17:58:59 +00:00
def allow_this_picture?
end
2021-10-27 22:58:58 +00:00
CRYSTAL
2017-11-01 13:20:04 +00:00
end
it "fails if predicate name is wrong" do
2021-10-27 22:58:58 +00:00
expect_issue subject, <<-CRYSTAL
2017-11-01 13:20:04 +00:00
def is_valid?(x)
2021-10-27 22:58:58 +00:00
# ^^^^^^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?'
2017-11-01 13:20:04 +00:00
end
2021-10-27 22:58:58 +00:00
CRYSTAL
2017-11-01 13:20:04 +00:00
end
it "ignores if alternative name isn't valid syntax" do
2021-10-27 22:58:58 +00:00
expect_no_issues subject, <<-CRYSTAL
class Image
def is_404?(x)
true
end
end
2021-10-27 22:58:58 +00:00
CRYSTAL
end
2017-11-01 13:20:04 +00:00
end
end