aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorGautham Goli2017-08-14 01:25:44 +0530
committerGautham Goli2017-08-14 01:25:44 +0530
commit6dad9d8b44e22f2729a2db95a1c2d14b3e84d477 (patch)
tree30fbe74641397f331d4d3c0c2ed49ba52a8c45ea /Library/Homebrew/test
parent7dfe09ccae5b1a8309326e5a5cb3172fbcd795d3 (diff)
downloadbrew-6dad9d8b44e22f2729a2db95a1c2d14b3e84d477.tar.bz2
Add test for top level method def
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/rubocops/lines_cop_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
index 1af5d2e72..00543f545 100644
--- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
@@ -596,6 +596,29 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
expect_offense(expected, actual)
end
end
+ it "with a top-level function def " do
+ source = <<-EOS.undent
+ def test
+ nil
+ end
+ class Foo < Formula
+ desc "foo"
+ url 'http://example.com/foo-1.0.tgz'
+ end
+ EOS
+
+ expected_offenses = [{ message: "Define method test in the class body, not at the top-level",
+ severity: :convention,
+ line: 1,
+ column: 0,
+ 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])