add test for ARGV.include?
This commit is contained in:
parent
3fc6cc1a3a
commit
2f94d5f499
@ -167,12 +167,12 @@ module RuboCop
|
||||
problem "Use `depends_on :fortran` instead of `ENV.fortran`"
|
||||
end
|
||||
|
||||
# find_instance_method_call(body_node, :ARGV, :include?) do |m|
|
||||
# param = parameters(m).first
|
||||
# next unless match = regex_match_group(param, %r{--(HEAD|devel)})
|
||||
# problem "Use \"if build.#{match[1].downcase}?\" instead"
|
||||
# end
|
||||
#
|
||||
find_instance_method_call(body_node, "ARGV", :include?) do |m|
|
||||
param = parameters(m).first
|
||||
next unless match = regex_match_group(param, %r{--(HEAD|devel)})
|
||||
problem "Use \"if build.#{match[1].downcase}?\" instead"
|
||||
end
|
||||
|
||||
# find_const(body_node, :MACOS_VERSION) do
|
||||
# problem "Use MacOS.version instead of MACOS_VERSION"
|
||||
# end
|
||||
|
||||
@ -1165,6 +1165,30 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
||||
end
|
||||
end
|
||||
|
||||
it "with ARGV.include? (--HEAD)" do
|
||||
source = <<-EOS.undent
|
||||
class Foo < Formula
|
||||
desc "foo"
|
||||
url 'http://example.com/foo-1.0.tgz'
|
||||
test do
|
||||
head = ARGV.include? "--HEAD"
|
||||
end
|
||||
end
|
||||
EOS
|
||||
|
||||
expected_offenses = [{ message: "Use \"if build.head?\" instead",
|
||||
severity: :convention,
|
||||
line: 5,
|
||||
column: 26,
|
||||
source: source }]
|
||||
|
||||
inspect_source(cop, source)
|
||||
|
||||
expected_offenses.zip(cop.offenses).each do |expected, actual|
|
||||
expect_offense(expected, actual)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
def expect_offense(expected, actual)
|
||||
expect(actual.message).to eq(expected[:message])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user