From 1c5bfa3d80fad8abd98165bf17c4ea326666a682 Mon Sep 17 00:00:00 2001 From: Bevan Kay Date: Mon, 30 Sep 2024 23:11:00 +1000 Subject: [PATCH] test/formula_auditor_spec: audit deprecate/disable reasons --- Library/Homebrew/test/formula_auditor_spec.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Library/Homebrew/test/formula_auditor_spec.rb b/Library/Homebrew/test/formula_auditor_spec.rb index 6889b7ed95..8b363aebd2 100644 --- a/Library/Homebrew/test/formula_auditor_spec.rb +++ b/Library/Homebrew/test/formula_auditor_spec.rb @@ -1312,4 +1312,35 @@ RSpec.describe Homebrew::FormulaAuditor do .to match("Formula foo should also have a conflict declared with bar") end end + + describe "#audit_deprecate_disable" do + specify "it warns when deprecate/disable reason is invalid" do + fa = formula_auditor "foo", <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + deprecate! date: "2021-01-01", because: :foobar + end + RUBY + + mkdir_p fa.formula.prefix + fa.audit_deprecate_disable + expect(fa.problems.first[:message]) + .to match("foobar is not a valid deprecate! or disable! reason") + end + + specify "it does not warn when deprecate/disable reason is valid" do + fa = formula_auditor "foo", <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + deprecate! date: "2021-01-01", because: :repo_archived + end + RUBY + + mkdir_p fa.formula.prefix + fa.audit_deprecate_disable + expect(fa.problems).to be_empty + end + end end