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

45 lines
1.2 KiB
Ruby
Raw Normal View History

require_relative "../../rubocops/components_redundancy_cop"
describe RuboCop::Cop::FormulaAuditStrict::ComponentsRedundancy do
subject(:cop) { described_class.new }
context "When auditing formula components common errors" do
it "When url outside stable block" do
2017-10-21 03:12:50 +02:00
expect_offense(<<~RUBY)
class Foo < Formula
url "http://example.com/foo-1.0.tgz"
2017-10-21 03:12:50 +02:00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `url` should be put inside `stable` block
stable do
# stuff
end
end
2017-10-21 03:12:50 +02:00
RUBY
end
it "When both `head` and `head do` are present" do
2017-10-21 03:12:50 +02:00
expect_offense(<<~RUBY)
class Foo < Formula
head "http://example.com/foo.git"
head do
2017-10-21 03:12:50 +02:00
^^^^^^^ `head` and `head do` should not be simultaneously present
# stuff
end
end
2017-10-21 03:12:50 +02:00
RUBY
end
it "When both `bottle :modifier` and `bottle do` are present" 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
2017-10-21 03:12:50 +02:00
^^^^^^^^^ `bottle :modifier` and `bottle do` should not be simultaneously present
# bottles go here
end
bottle :unneeded
end
2017-10-21 03:12:50 +02:00
RUBY
end
end
end