2018-06-16 11:50:59 +00:00
|
|
|
require "../../../spec_helper"
|
2017-11-01 13:20:04 +00:00
|
|
|
|
2018-06-16 11:50:59 +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
|
|
|
|
|
2018-04-12 12:52:09 +00:00
|
|
|
it "ignores if alternative name isn't valid syntax" do
|
2021-10-27 22:58:58 +00:00
|
|
|
expect_no_issues subject, <<-CRYSTAL
|
2018-04-12 12:52:09 +00:00
|
|
|
class Image
|
|
|
|
def is_404?(x)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
2021-10-27 22:58:58 +00:00
|
|
|
CRYSTAL
|
2018-04-12 12:52:09 +00:00
|
|
|
end
|
2017-11-01 13:20:04 +00:00
|
|
|
end
|
|
|
|
end
|