test/formula_auditor_spec: audit deprecate/disable reasons

This commit is contained in:
Bevan Kay 2024-09-30 23:11:00 +10:00
parent 905322dc0d
commit 1c5bfa3d80
No known key found for this signature in database
GPG Key ID: C55CB024B5314B57

View File

@ -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