aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/rubocops/bottle_block_cop_spec.rb
blob: e0982dcbab292ea5d51a1e43613b531b569e4e6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require_relative "../../rubocops/bottle_block_cop"

describe RuboCop::Cop::FormulaAuditStrict::BottleBlock do
  subject(:cop) { described_class.new }

  context "When auditing Bottle Block" do
    it "When there is revision in bottle block" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'http://example.com/foo-1.0.tgz'
          bottle do
            cellar :any
            revision 2
            ^^^^^^^^^^ Use rebuild instead of revision in bottle block
          end
        end
      RUBY
    end
  end

  context "When auditing Bottle Block with auto correct" do
    it "When there is revision in bottle block" do
      source = <<~EOS
        class Foo < Formula
          url 'http://example.com/foo-1.0.tgz'
          bottle do
            cellar :any
            revision 2
          end
        end
      EOS

      corrected_source = <<~EOS
        class Foo < Formula
          url 'http://example.com/foo-1.0.tgz'
          bottle do
            cellar :any
            rebuild 2
          end
        end
      EOS

      new_source = autocorrect_source(source)
      expect(new_source).to eq(corrected_source)
    end
  end
end