From 644ae115f56de90a72ab0fac68d5bdac906cf82e Mon Sep 17 00:00:00 2001 From: Frank Lam Date: Thu, 25 Jun 2020 22:29:34 +0800 Subject: [PATCH] Prepare inline patch specs --- .../Homebrew/test/rubocops/patches_spec.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Library/Homebrew/test/rubocops/patches_spec.rb b/Library/Homebrew/test/rubocops/patches_spec.rb index f2a0fc25a7..6b0fc2a1a5 100644 --- a/Library/Homebrew/test/rubocops/patches_spec.rb +++ b/Library/Homebrew/test/rubocops/patches_spec.rb @@ -163,6 +163,40 @@ describe RuboCop::Cop::FormulaAudit::Patches do end end + context "When auditing inline patches" do + it "reports no offenses for valid inline patches" do + expect_no_offenses(<<~RUBY) + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + patch :DATA + end + __END__ + patch content here + RUBY + end + + it "reports an offense when DATA is found with no __END__" do + expect_offense(<<~RUBY) + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + patch :DATA + ^^^^^^^^^^^ patch is missing '__END__' + end + RUBY + end + + it "reports an offense when __END__ is found with no DATA" do + expect_offense(<<~RUBY) + class Foo < Formula + url 'https://brew.sh/foo-1.0.tgz' + end + __END__ + ^^^^^^^ patch is missing 'DATA' + patch content here + RUBY + end + end + context "When auditing external patches" do it "Patch URLs" do patch_urls = [