diff options
| author | Mike McQuaid | 2017-05-14 14:54:14 +0100 |
|---|---|---|
| committer | GitHub | 2017-05-14 14:54:14 +0100 |
| commit | 8e4e9d877c2bebe635b1481a1841f5852535f15e (patch) | |
| tree | d5dfdbdddddc9049e0b4223295fd375cfffef0cb /Library/Homebrew/test | |
| parent | 459fef3b09b25d3e24cce6aa6f2e3a7bd5460a2b (diff) | |
| parent | d04f295de3ed63a7f435f6a4aacb447747e58574 (diff) | |
| download | brew-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.rb | 47 |
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 |
