aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorGautham Goli2017-08-15 00:29:58 +0530
committerGautham Goli2017-08-15 00:29:58 +0530
commit5744cd9066bbdfc4db5332a202ddb962d5359ee5 (patch)
treebe0cea0c1d23e0d8a01daff0684a5f4dfaa1a63c /Library/Homebrew/test
parentcfc423e1839442f605072db14aac42f6f5fa6174 (diff)
downloadbrew-5744cd9066bbdfc4db5332a202ddb962d5359ee5.tar.bz2
add test for inspecting version
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/rubocops/lines_cop_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
index 1273ef9c9..f24a6b09d 100644
--- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
@@ -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])