diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 0f444b1153..3f6d6e3b32 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -126,6 +126,7 @@ class Tap @formula_dir = nil @cask_dir = nil @command_dir = nil + @formula_names = nil @formula_files = nil @cask_files = nil @alias_dir = nil diff --git a/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb b/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb index e49d7f1de6..39112a8ee6 100644 --- a/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb +++ b/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb @@ -31,7 +31,23 @@ RSpec.describe "Internal Tap JSON -- Formula" do allow(Homebrew::API).to receive(:fetch_json_api_file) .with("internal/v3/homebrew-core.jws.json") - .and_return(JSON.parse(internal_tap_json), false) + .and_return([JSON.parse(internal_tap_json), false]) + + # `Tap.reverse_tap_migrations_renames` looks for renames in every + # tap so `CoreCaskTap.tap_migrations` gets called and tries to + # fetch stuff from the API. This just avoids errors. + allow(Homebrew::API).to receive(:fetch_json_api_file) + .with("cask_tap_migrations.jws.json", anything) + .and_return([{}, false]) + + # To allow `formula_names.txt` to be written to the cache. + (HOMEBREW_CACHE/"api").mkdir + + Homebrew::API::Formula.clear_cache + end + + after do + Homebrew::API::Formula.clear_cache end it "loads tap aliases" do