style: add tests for provided_by_macos and style_exceptions
This commit is contained in:
parent
f8ff0f465f
commit
0c41d374c9
61
Library/Homebrew/test/rubocops/provided_by_macos_spec.rb
Normal file
61
Library/Homebrew/test/rubocops/provided_by_macos_spec.rb
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "rubocops/uses_from_macos"
|
||||||
|
|
||||||
|
describe RuboCop::Cop::FormulaAudit::ProvidedByMacos do
|
||||||
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
|
let(:path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" }
|
||||||
|
|
||||||
|
before do
|
||||||
|
path.mkpath
|
||||||
|
(path/"style_exceptions").mkpath
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_style_exceptions
|
||||||
|
(path/"style_exceptions/provided_by_macos_formulae.json").write <<~JSON
|
||||||
|
[ "foo", "bar" ]
|
||||||
|
JSON
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails for formulae not in provided_by_macos_formulae list" do
|
||||||
|
setup_style_exceptions
|
||||||
|
|
||||||
|
expect_offense(<<~RUBY, "#{path}/Formula/baz.rb")
|
||||||
|
class Baz < Formula
|
||||||
|
url "https://brew.sh/baz-1.0.tgz"
|
||||||
|
homepage "https://brew.sh"
|
||||||
|
|
||||||
|
keg_only :provided_by_macos
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae that are `keg_only :provided_by_macos` should be added to `style_exceptions/provided_by_macos_formulae.json`
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
it "succeeds for formulae in provided_by_macos_formulae list" do
|
||||||
|
setup_style_exceptions
|
||||||
|
|
||||||
|
expect_no_offenses(<<~RUBY, "#{path}/Formula/foo.rb")
|
||||||
|
class Foo < Formula
|
||||||
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
homepage "https://brew.sh"
|
||||||
|
|
||||||
|
keg_only :provided_by_macos
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
it "succeeds for formulae that are keg_only for a different reason" do
|
||||||
|
setup_style_exceptions
|
||||||
|
|
||||||
|
expect_no_offenses(<<~RUBY, "#{path}/Formula/foo.rb")
|
||||||
|
class Baz < Formula
|
||||||
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
|
homepage "https://brew.sh"
|
||||||
|
|
||||||
|
keg_only :versioned_formula
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user