@@ -1728,32 +1728,77 @@ class Foo < Formula
17281728 end
17291729
17301730 describe "#audit_no_autobump" do
1731- it "warns when autobump exclusion reason is not suitable for new formula" do
1732- fa = formula_auditor "foo" , <<~RUBY , new_formula : true
1733- class Foo < Formula
1734- url "https://brew.sh/foo-1.0.tgz"
1731+ subject ( :no_autobump_audit ) do
1732+ fa = described_class . new ( Formulary . factory ( formula_path ) , git : true )
1733+ fa . audit_no_autobump
1734+ fa . problems . first &.fetch ( :message )
1735+ end
1736+
1737+ before do
1738+ origin_formula_path . dirname . mkpath
1739+ origin_formula_path . write <<~RUBY
1740+ class Foo#{ foo_version } < Formula
1741+ url "https://brew.sh/foo-1.0.tar.gz"
1742+ sha256 "31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e"
17351743
1736- no_autobump! because: :requires_manual_review
1744+ no_autobump! because: "no_autobump_placeholder"
17371745 end
17381746 RUBY
17391747
1740- fa . audit_no_autobump
1741- expect ( fa . new_formula_problems . first [ :message ] )
1742- . to match ( "`:requires_manual_review` is a temporary reason intended for existing packages, " \
1743- "use a different reason instead." )
1748+ origin_tap_path . mkpath
1749+ origin_tap_path . cd do
1750+ system "git" , "init"
1751+ system "git" , "add" , "--all"
1752+ system "git" , "commit" , "-m" , "init"
1753+ end
1754+
1755+ tap_path . mkpath
1756+ tap_path . cd do
1757+ system "git" , "clone" , origin_tap_path , "."
1758+ end
17441759 end
17451760
1746- it "does not warn when autobump exclusion reason is allowed" do
1747- fa = formula_auditor "foo" , <<~RUBY , new_formula : true
1748- class Foo < Formula
1749- url "https://brew.sh/foo-1.0.tgz"
1761+ describe "no_autobump" do
1762+ context "when version is changed" do
1763+ before do
1764+ formula_gsub "foo-1.0.tar.gz" , "foo-1.1.tar.gz"
1765+ formula_gsub '"no_autobump_placeholder"' , ":requires_manual_review"
1766+ end
17501767
1751- no_autobump! because: "foo bar"
1768+ it do
1769+ expect ( no_autobump_audit ) . to match ( "`:requires_manual_review` is a temporary to-be deprecated reason, " \
1770+ "change or remove autobump exclusion reason." )
17521771 end
1753- RUBY
1772+ end
17541773
1755- fa . audit_no_autobump
1756- expect ( fa . new_formula_problems ) . to be_empty
1774+ context "when version is not changed" do
1775+ before do
1776+ formula_gsub "foo-1.0.tar.gz" , "foo-1.1.tar.gz"
1777+ end
1778+
1779+ it { is_expected . to be_nil }
1780+ end
1781+
1782+ context "when autobump exclusion reason is not `:requires_manual_review`" do
1783+ it { is_expected . to be_nil }
1784+ end
1785+
1786+ context "when a new formula is created" do
1787+ it "warns when autobump exclusion reason is not suitable for new formula" do
1788+ fa = formula_auditor "foo" , <<~RUBY , new_formula : true
1789+ class Foo < Formula
1790+ url "https://brew.sh/foo-1.0.tgz"
1791+
1792+ no_autobump! because: :requires_manual_review
1793+ end
1794+ RUBY
1795+
1796+ fa . audit_no_autobump
1797+ expect ( fa . new_formula_problems . first [ :message ] )
1798+ . to match ( "`:requires_manual_review` is a temporary to-be deprecated reason, " \
1799+ "use a different reason instead." )
1800+ end
1801+ end
17571802 end
17581803 end
17591804end
0 commit comments