Skip to content
Snippets Groups Projects
Commit 5744cd90 authored by Gautham Goli's avatar Gautham Goli
Browse files

add test for inspecting version

parent cfc423e1
No related branches found
No related tags found
No related merge requests found
......@@ -157,11 +157,11 @@ module RuboCop
problem "Dependency #{string_content(dep)} should not use option #{string_content(option)}"
end
# find_instance_method_call(body_node, :version, :==) do |m|
# next unless parameters_passed?(m, "HEAD")
# problem "Use 'build.head?' instead of inspecting 'version'"
# end
#
find_instance_method_call(body_node, :version, :==) do |m|
next unless parameters_passed?(m, "HEAD")
problem "Use 'build.head?' instead of inspecting 'version'"
end
# find_instance_method_call(body_node, :ENV, :fortran) do
# next if depends_on?(:fortran)
# problem "Use `depends_on :fortran` instead of `ENV.fortran`"
......
......@@ -1117,6 +1117,30 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
end
end
it "with inspecting version" do
source = <<-EOS.undent
class Foo < Formula
desc "foo"
url 'http://example.com/foo-1.0.tgz'
if version == "HEAD"
foo()
end
end
EOS
expected_offenses = [{ message: "Use 'build.head?' instead of inspecting 'version'",
severity: :convention,
line: 4,
column: 5,
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])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment