brew/Library/Homebrew/test/rubocops/provided_by_macos_spec.rb
Issy Long da734a30c2
Say yes to RuboCop's DisplayCopNames; fix test expectations
- Fixing the test expected output was unbelievably tedious.
- There's been debate about this setting being `false` but in
  https://github.com/Homebrew/brew/pull/15136#issuecomment-1500063225
  we decided that it was worth using the default since RuboCop behaviour changed
  so we'd have had to do some horrible things to keep it as `false` -
  https://github.com/Homebrew/brew/pull/15136#issuecomment-1500037278 -
  and multiple maintainers specify the `--display-cop-names` option to
  `brew style` themselves since it's clearer what's gone wrong.
2023-04-07 19:14:07 +01:00

45 lines
1.3 KiB
Ruby

# typed: false
# frozen_string_literal: true
require "rubocops/uses_from_macos"
describe RuboCop::Cop::FormulaAudit::ProvidedByMacos do
subject(:cop) { described_class.new }
it "fails for formulae not in PROVIDED_BY_MACOS_FORMULAE list" do
expect_offense(<<~RUBY)
class Baz < Formula
url "https://brew.sh/baz-1.0.tgz"
homepage "https://brew.sh"
keg_only :provided_by_macos
^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/ProvidedByMacos: Formulae that are `keg_only :provided_by_macos` should be added to the `PROVIDED_BY_MACOS_FORMULAE` list (in the Homebrew/brew repo)
end
RUBY
end
it "succeeds for formulae in PROVIDED_BY_MACOS_FORMULAE list" do
expect_no_offenses(<<~RUBY, "/homebrew-core/Formula/apr.rb")
class Apr < Formula
url "https://brew.sh/apr-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
expect_no_offenses(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
homepage "https://brew.sh"
keg_only :versioned_formula
end
RUBY
end
include_examples "formulae exist", described_class::PROVIDED_BY_MACOS_FORMULAE
end