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

71 lines
2.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require "rubocops/options"
RSpec.describe RuboCop::Cop::FormulaAudit::Options do
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
url 'https://brew.sh/foo-1.0.tgz'
2018-10-27 21:47:58 +10:00
option "with-32-bit"
^^^^^^^^^^^^^ 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
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)
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
option :universal
^^^^^^^^^^^^^^^^^ FormulaAudit/Options: macOS has been 64-bit only since 10.6 so universal options are deprecated.
end
2017-10-21 03:12:50 +02:00
RUBY
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)
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
option :cxx11
option "examples", "with-examples"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Options should begin with `with` or `without`. Migrate '--examples' with `deprecated_option`.
end
2017-10-21 03:12:50 +02:00
RUBY
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)
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
option "without-check"
^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Use '--without-test' instead of '--without-check'. Migrate '--without-check' with `deprecated_option`.
end
2017-10-21 03:12:50 +02:00
RUBY
end
2021-01-12 18:16:26 +11:00
it "reports an offense when using `deprecated_option` in homebrew/core" do
expect_offense(<<~RUBY, "/homebrew-core/")
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
deprecated_option "examples" => "with-examples"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Formulae in homebrew/core should not use `deprecated_option`.
end
2017-10-21 03:12:50 +02:00
RUBY
end
2021-01-12 18:16:26 +11:00
it "reports an offense when using `option` in homebrew/core" do
expect_offense(<<~RUBY, "/homebrew-core/")
class Foo < Formula
url 'https://brew.sh/foo-1.0.tgz'
option "with-examples"
^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/Options: Formulae in homebrew/core should not use `option`.
end
RUBY
end
end
end