2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-26 19:41:14 +01:00
|
|
|
require "rubocops/options"
|
2017-05-24 21:07:50 +05:30
|
|
|
|
2024-02-18 15:11:11 -08:00
|
|
|
RSpec.describe RuboCop::Cop::FormulaAudit::Options do
|
2017-05-24 21:07:50 +05:30
|
|
|
subject(:cop) { described_class.new }
|
|
|
|
|
2021-01-14 18:55:31 -08:00
|
|
|
context "when auditing options" do
|
2018-10-27 21:47:58 +10:00
|
|
|
it "reports an offense when using the 32-bit option" do
|
|
|
|
expect_offense(<<~RUBY)
|
|
|
|
class Foo < Formula
|
2018-11-28 20:51:55 +01:00
|
|
|
url 'https://brew.sh/foo-1.0.tgz'
|
2018-10-27 21:47:58 +10:00
|
|
|
option "with-32-bit"
|
2023-04-07 17:16:48 +01:00
|
|
|
^^^^^^^^^^^^^ FormulaAudit/Options: macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
|
2018-10-27 21:47:58 +10:00
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
2017-07-14 21:11:53 +05:30
|
|
|
|
2021-01-12 18:16:26 +11:00
|
|
|
it "reports an offense when using `:universal`" do
|
2017-10-21 03:12:50 +02:00
|
|
|
expect_offense(<<~RUBY)
|
2017-07-14 21:11:53 +05:30
|
|
|
class Foo < Formula
|
2018-11-28 20:51:55 +01:00
|
|
|
url 'https://brew.sh/foo-1.0.tgz'
|
2017-07-14 21:11:53 +05:30
|
|
|
option :universal
|
2023-04-07 17:16:48 +01:00
|
|
|
^^^^^^^^^^^^^^^^^ FormulaAudit/Options: macOS has been 64-bit only since 10.6 so universal options are deprecated.
|
2017-07-14 21:11:53 +05:30
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-07-14 21:11:53 +05:30
|
|
|
end
|
|
|
|
|
2021-01-12 18:16:26 +11:00
|
|
|
it "reports an offense when using bad option names" do
|
2017-10-21 03:12:50 +02:00
|
|
|
expect_offense(<<~RUBY)
|
2017-07-14 21:11:53 +05:30
|
|
|
class Foo < Formula
|
2018-11-28 20:51:55 +01:00
|
|
|
url 'https://brew.sh/foo-1.0.tgz'
|
2017-07-14 21:11:53 +05:30
|
|
|
option :cxx11
|
|
|
|
option "examples", "with-examples"
|
2023-04-07 17:16:48 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Options should begin with with/without. Migrate '--examples' with `deprecated_option`.
|
2017-07-14 21:11:53 +05:30
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-07-14 21:11:53 +05:30
|
|
|
end
|
|
|
|
|
2021-01-12 18:16:26 +11:00
|
|
|
it "reports an offense when using `without-check` option names" do
|
2017-10-21 03:12:50 +02:00
|
|
|
expect_offense(<<~RUBY)
|
2017-07-14 21:11:53 +05:30
|
|
|
class Foo < Formula
|
2018-11-28 20:51:55 +01:00
|
|
|
url 'https://brew.sh/foo-1.0.tgz'
|
2017-07-14 21:11:53 +05:30
|
|
|
option "without-check"
|
2023-04-07 17:16:48 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Use '--without-test' instead of '--without-check'. Migrate '--without-check' with `deprecated_option`.
|
2017-07-14 21:11:53 +05:30
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-07-14 21:11:53 +05:30
|
|
|
end
|
2017-07-15 13:34:16 +05:30
|
|
|
|
2021-01-12 18:16:26 +11:00
|
|
|
it "reports an offense when using `deprecated_option` in homebrew/core" do
|
2019-01-22 13:30:24 +00:00
|
|
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
2017-07-15 13:34:16 +05:30
|
|
|
class Foo < Formula
|
2018-11-28 20:51:55 +01:00
|
|
|
url 'https://brew.sh/foo-1.0.tgz'
|
2017-07-15 13:34:16 +05:30
|
|
|
deprecated_option "examples" => "with-examples"
|
2023-04-07 17:16:48 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Formulae in homebrew/core should not use `deprecated_option`.
|
2017-07-15 13:34:16 +05:30
|
|
|
end
|
2017-10-21 03:12:50 +02:00
|
|
|
RUBY
|
2017-07-15 13:34:16 +05:30
|
|
|
end
|
2018-05-22 19:39:10 +10:00
|
|
|
|
2021-01-12 18:16:26 +11:00
|
|
|
it "reports an offense when using `option` in homebrew/core" do
|
2018-05-22 19:39:10 +10:00
|
|
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
|
|
|
class Foo < Formula
|
2018-11-28 20:51:55 +01:00
|
|
|
url 'https://brew.sh/foo-1.0.tgz'
|
2018-05-22 19:39:10 +10:00
|
|
|
option "with-examples"
|
2023-04-07 17:16:48 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Formulae in homebrew/core should not use `option`.
|
2018-05-22 19:39:10 +10:00
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
2017-07-15 13:34:16 +05:30
|
|
|
end
|
|
|
|
end
|