2017-04-08 15:10:44 +05:30
|
|
|
require_relative "../../rubocops/components_redundancy_cop"
|
|
|
|
|
2017-05-03 11:33:00 +05:30
|
|
|
describe RuboCop::Cop::FormulaAuditStrict::ComponentsRedundancy do
|
2017-04-08 15:10:44 +05:30
|
|
|
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)
|
2017-04-08 15:10:44 +05:30
|
|
|
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
|
2017-04-08 15:10:44 +05:30
|
|
|
stable do
|
|
|
|
# stuff
|
|
|
|
end
|
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-04-08 15:10:44 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it "When both `head` and `head do` are present" do
|
2017-10-21 03:12:50 +02:00
|
|
|
expect_offense(<<~RUBY)
|
2017-04-08 15:10:44 +05:30
|
|
|
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
|
2017-04-08 15:10:44 +05:30
|
|
|
# stuff
|
|
|
|
end
|
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-04-08 15:10:44 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it "When both `bottle :modifier` and `bottle do` are present" do
|
2017-10-21 03:12:50 +02:00
|
|
|
expect_offense(<<~RUBY)
|
2017-04-08 15:10:44 +05:30
|
|
|
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
|
2017-04-08 15:10:44 +05:30
|
|
|
# bottles go here
|
|
|
|
end
|
|
|
|
bottle :unneeded
|
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-04-08 15:10:44 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|