2017-03-08 13:51:35 +05:30
|
|
|
require_relative "../../rubocops/bottle_block_cop"
|
|
|
|
|
2017-05-03 11:33:00 +05:30
|
|
|
describe RuboCop::Cop::FormulaAuditStrict::BottleBlock do
|
2017-03-08 13:51:35 +05:30
|
|
|
subject(:cop) { described_class.new }
|
|
|
|
|
|
|
|
context "When auditing Bottle Block" do
|
|
|
|
it "When there is revision in bottle block" do
|
2017-10-21 03:12:50 +02:00
|
|
|
expect_offense(<<~RUBY)
|
2017-03-08 13:51:35 +05:30
|
|
|
class Foo < Formula
|
|
|
|
url 'http://example.com/foo-1.0.tgz'
|
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
revision 2
|
2017-10-21 03:12:50 +02:00
|
|
|
^^^^^^^^^^ Use rebuild instead of revision in bottle block
|
2017-03-08 13:51:35 +05:30
|
|
|
end
|
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-03-08 13:51:35 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "When auditing Bottle Block with auto correct" do
|
|
|
|
it "When there is revision in bottle block" do
|
2017-10-15 02:28:32 +02:00
|
|
|
source = <<~EOS
|
2017-03-08 13:51:35 +05:30
|
|
|
class Foo < Formula
|
|
|
|
url 'http://example.com/foo-1.0.tgz'
|
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
revision 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOS
|
2017-10-21 03:12:50 +02:00
|
|
|
|
2017-10-15 02:28:32 +02:00
|
|
|
corrected_source = <<~EOS
|
2017-03-08 13:51:35 +05:30
|
|
|
class Foo < Formula
|
|
|
|
url 'http://example.com/foo-1.0.tgz'
|
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
rebuild 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOS
|
|
|
|
|
2017-10-07 22:31:23 +02:00
|
|
|
new_source = autocorrect_source(source)
|
2017-03-08 13:51:35 +05:30
|
|
|
expect(new_source).to eq(corrected_source)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|