aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorGautham Goli2017-08-14 01:55:47 +0530
committerGautham Goli2017-08-14 01:55:47 +0530
commitec2b0df10e62152529386cf2a696f9aaece405ea (patch)
tree50d9d8601e2bc57d86237e4faec9c4b2f4d821b6 /Library/Homebrew/test
parentf968776e8460d7b6a0a3199d9c92c945cda0738d (diff)
downloadbrew-ec2b0df10e62152529386cf2a696f9aaece405ea.tar.bz2
Add tests for unless build.with?
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 352dc8219..dda1b96e6 100644
--- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
@@ -643,6 +643,30 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
expect_offense(expected, actual)
end
end
+
+ it "with unless build.with?" do
+ source = <<-EOS.undent
+ class Foo < Formula
+ desc "foo"
+ url 'http://example.com/foo-1.0.tgz'
+ def post_install
+ return unless build.with? "bar"
+ end
+ end
+ EOS
+
+ expected_offenses = [{ message: 'Use if build.without? "bar" instead of unless build.with? "bar"',
+ severity: :convention,
+ line: 5,
+ column: 18,
+ 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])