brew/Library/Homebrew/test/rubocops/components_redundancy_spec.rb
Claudia 5be80a78f6
Use Homebrew-controlled domain for Cask dummy URLs
In a number of Cask specs, the value of the `homepage` stanza is currently set
to https://example.com. As of 2018-11-28, the TLS certificate served by
example.com seems to be expired, possibly due to an oversight on ICANN’s side.

While the certificate is certainly going to be renewed soon, it would be
desirable for Homebrew’s test result to be less dependent on ICANN’s actions.
This commit changes the homepages of all test Casks to http://brew.sh, whose
domain and TLS certificate are both controlled by Homebrew.
2018-11-28 20:51:55 +01:00

89 lines
2.0 KiB
Ruby

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
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
devel do
# stuff
end
end
RUBY
end
it "When both `head` and `head do` are present" do
expect_offense(<<~RUBY)
class Foo < Formula
head "https://brew.sh/foo.git"
head do
^^^^^^^ `head` and `head do` should not be simultaneously present
# stuff
end
end
RUBY
end
it "When both `bottle :modifier` and `bottle do` are present" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
bottle do
^^^^^^^^^ `bottle :modifier` and `bottle do` should not be simultaneously present
# bottles go here
end
bottle :unneeded
end
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
it "When `stable do` is present with a `devel` block" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
stable do
# stuff
end
devel do
# stuff
end
end
RUBY
end
end
end