aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorGautham Goli2017-05-24 13:04:55 +0530
committerGautham Goli2017-07-07 20:46:57 +0530
commit4ed34f91c26b3b3449d676fa2067222d318c4d3a (patch)
tree8a92eee4adb12ba728070ed97600065c8389dd9f /Library/Homebrew/test
parentb5529084906af89827f6d9befd613457a1615918 (diff)
downloadbrew-4ed34f91c26b3b3449d676fa2067222d318c4d3a.tar.bz2
audit: Port audit_conflicts method to rubocop and add tests
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/rubocops/conflicts_cop_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/conflicts_cop_spec.rb b/Library/Homebrew/test/rubocops/conflicts_cop_spec.rb
new file mode 100644
index 000000000..c3175509a
--- /dev/null
+++ b/Library/Homebrew/test/rubocops/conflicts_cop_spec.rb
@@ -0,0 +1,47 @@
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../extend/string"
+require_relative "../../rubocops/conflicts_cop"
+
+describe RuboCop::Cop::FormulaAudit::Conflicts do
+ subject(:cop) { described_class.new }
+
+ context "When auditing formula for conflicts with" do
+ it "multiple conflicts_with" do
+ source = <<-EOS.undent
+ class FooAT20 < Formula
+ url 'http://example.com/foo-2.0.tgz'
+ conflicts_with "mysql", "mariadb", "percona-server",
+ :because => "both install plugins"
+ end
+ EOS
+
+ msg = <<-EOS.undent
+ Versioned formulae should not use `conflicts_with`.
+ Use `keg_only :versioned_formula` instead.
+ EOS
+ expected_offenses = [{ message: msg,
+ severity: :convention,
+ line: 3,
+ column: 2,
+ source: source }]
+
+ inspect_source(cop, source)
+
+ expected_offenses.zip(cop.offenses).each do |expected, actual|
+ expect_offense(expected, actual)
+ end
+ end
+
+ it "no conflicts_with" do
+ source = <<-EOS.undent
+ class FooAT20 < Formula
+ url 'http://example.com/foo-2.0.tgz'
+ desc 'Bar'
+ end
+ EOS
+ inspect_source(cop, source)
+ expect(cop.offenses).to eq([])
+ end
+ end
+end