aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMike McQuaid2017-08-01 11:29:26 +0100
committerGitHub2017-08-01 11:29:26 +0100
commitc3c3575b7055e633d6f7930c2ab0e7e7d9b9b82f (patch)
tree65e38afd5476d1bab6d9f703053d613985e7ed62 /Library/Homebrew/test
parent4788e0a98e2c36ecea9ae3ae4efba99b60fa3a63 (diff)
parente1cb0b43d7e3095de97b63c4776f9709120b7fad (diff)
downloadbrew-c3c3575b7055e633d6f7930c2ab0e7e7d9b9b82f.tar.bz2
Merge pull request #2964 from GauthamGoli/audit_line_rubocop_part_1
audit: Port dependency rules from line_problems to rubocop and add tests
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/rubocops/lines_cop_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
new file mode 100644
index 000000000..c865e1480
--- /dev/null
+++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb
@@ -0,0 +1,53 @@
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../extend/string"
+require_relative "../../rubocops/lines_cop"
+
+describe RuboCop::Cop::FormulaAudit::Lines do
+ subject(:cop) { described_class.new }
+
+ context "When auditing lines" do
+ it "with correctable deprecated dependencies" do
+ formulae = [{
+ "dependency" => :automake,
+ "correct" => "automake",
+ }, {
+ "dependency" => :autoconf,
+ "correct" => "autoconf",
+ }, {
+ "dependency" => :libtool,
+ "correct" => "libtool",
+ }, {
+ "dependency" => :apr,
+ "correct" => "apr-util",
+ }, {
+ "dependency" => :tex,
+ }]
+
+ formulae.each do |formula|
+ source = <<-EOS.undent
+ class Foo < Formula
+ url 'http://example.com/foo-1.0.tgz'
+ depends_on :#{formula["dependency"]}
+ end
+ EOS
+ if formula.key?("correct")
+ offense = ":#{formula["dependency"]} is deprecated. Usage should be \"#{formula["correct"]}\""
+ else
+ offense = ":#{formula["dependency"]} is deprecated"
+ end
+ expected_offenses = [{ message: offense,
+ severity: :convention,
+ line: 3,
+ column: 2,
+ source: source }]
+
+ inspect_source(cop, source)
+
+ expected_offenses.zip(cop.offenses.reverse).each do |expected, actual|
+ expect_offense(expected, actual)
+ end
+ end
+ end
+ end
+end