Skip to content

Commit

Permalink
api/formula: Fix failing specs
Browse files Browse the repository at this point in the history
- clear the formula API cache
- make the API cache directory
- fix stubbed return values (thanks Sorbet!)
  • Loading branch information
apainintheneck committed Feb 25, 2024
1 parent d7d9174 commit 9134e7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Library/Homebrew/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def clear_cache
@formula_dir = nil
@cask_dir = nil
@command_dir = nil
@formula_names = nil
@formula_files = nil
@cask_files = nil
@alias_dir = nil
Expand Down
18 changes: 17 additions & 1 deletion Library/Homebrew/test/api/internal_tap_json/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,23 @@

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
Expand Down

0 comments on commit 9134e7e

Please sign in to comment.