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

78 lines
1.8 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "rubocops/components_redundancy"
describe RuboCop::Cop::FormulaAudit::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 "https://brew.sh/foo-1.0.tgz"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `url` should be put inside `stable` block
stable do
# stuff
end
head 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 "https://brew.sh/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 "https://brew.sh/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
it "When `stable do` is present with a `head` method" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
head "https://brew.sh/foo.git"
stable do
# stuff
end
end
RUBY
end
it "When `stable do` is present with a `head do` block" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
stable do
# stuff
end
head do
# stuff
end
end
RUBY
end
end
end