aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMike McQuaid2017-05-14 14:54:14 +0100
committerGitHub2017-05-14 14:54:14 +0100
commit8e4e9d877c2bebe635b1481a1841f5852535f15e (patch)
treed5dfdbdddddc9049e0b4223295fd375cfffef0cb /Library/Homebrew/test
parent459fef3b09b25d3e24cce6aa6f2e3a7bd5460a2b (diff)
parentd04f295de3ed63a7f435f6a4aacb447747e58574 (diff)
downloadbrew-8e4e9d877c2bebe635b1481a1841f5852535f15e.tar.bz2
Merge pull request #2610 from GauthamGoli/audit_components_autocorrect
Add autocorrect method for ComponentsOrder rubocop and tests
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/rubocops/components_order_cop_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/Library/Homebrew/test/rubocops/components_order_cop_spec.rb b/Library/Homebrew/test/rubocops/components_order_cop_spec.rb
index 05ff53d8f..25467c635 100644
--- a/Library/Homebrew/test/rubocops/components_order_cop_spec.rb
+++ b/Library/Homebrew/test/rubocops/components_order_cop_spec.rb
@@ -113,4 +113,51 @@ describe RuboCop::Cop::FormulaAuditStrict::ComponentsOrder do
expect(actual.column).to eq(expected[:column])
end
end
+
+ context "When auditing formula components order with autocorrect" do
+ it "When url precedes homepage" do
+ source = <<-EOS.undent
+ class Foo < Formula
+ url "http://example.com/foo-1.0.tgz"
+ homepage "http://example.com"
+ end
+ EOS
+ correct_source = <<-EOS.undent
+ class Foo < Formula
+ homepage "http://example.com"
+ url "http://example.com/foo-1.0.tgz"
+ end
+ EOS
+
+ corrected_source = autocorrect_source(cop, source)
+ expect(corrected_source).to eq(correct_source)
+ end
+
+ it "When `resource` precedes `depends_on`" do
+ source = <<-EOS.undent
+ class Foo < Formula
+ url "https://example.com/foo-1.0.tgz"
+
+ resource "foo2" do
+ url "https://example.com/foo-2.0.tgz"
+ end
+
+ depends_on "openssl"
+ end
+ EOS
+ correct_source = <<-EOS.undent
+ class Foo < Formula
+ url "https://example.com/foo-1.0.tgz"
+
+ depends_on "openssl"
+
+ resource "foo2" do
+ url "https://example.com/foo-2.0.tgz"
+ end
+ end
+ EOS
+ corrected_source = autocorrect_source(cop, source)
+ expect(corrected_source).to eq(correct_source)
+ end
+ end
end