brew/Library/Homebrew/test/rubocops/bottle_block_cop_spec.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

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
2017-10-21 03:12:50 +02:00
expect_offense(<<~RUBY)
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
end
end
2017-10-21 03:12:50 +02:00
RUBY
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
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
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)
expect(new_source).to eq(corrected_source)
end
end
end