diff options
| author | Gautham Goli | 2017-07-29 16:36:32 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-07-29 16:36:32 +0530 |
| commit | e1cb0b43d7e3095de97b63c4776f9709120b7fad (patch) | |
| tree | 61881aa40822d6b69b2da43fd5bc8921438a553b /Library/Homebrew/test | |
| parent | a49d99a2d6a22f9db1540cb546ac2d7be2fb5703 (diff) | |
| download | brew-e1cb0b43d7e3095de97b63c4776f9709120b7fad.tar.bz2 | |
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.rb | 53 |
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 |
