Merge pull request #16697 from apainintheneck/update-some-formulary-specs

formulary_spec: update API tests to avoid mocking
This commit is contained in:
Kevin 2024-02-18 23:47:30 -08:00 committed by GitHub
commit e5fefd73cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -1169,7 +1169,8 @@ class CoreTap < AbstractCoreTap
name, formula_hash = item
# If there's more than one item with the same path: use the longer one to prioritise more specific results.
existing_path = hash[name]
new_path = File.join(tap_path, formula_hash["ruby_source_path"]) # Pathname equivalent is slow in a tight loop
# Pathname equivalent is slow in a tight loop
new_path = File.join(tap_path, formula_hash.fetch("ruby_source_path"))
hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length
end
end

View File

@ -158,8 +158,6 @@ describe Formulary do
context "with installed Formula" do
before do
allow(described_class).to receive(:loader_for).and_call_original
# don't try to load/fetch gcc/glibc
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
end
@ -329,6 +327,7 @@ describe Formulary do
"run_type" => "immediate",
"working_dir" => "/$HOME",
},
"ruby_source_path" => "Formula/#{formula_name}.rb",
}.merge(extra_items),
}
end
@ -378,7 +377,7 @@ describe Formulary do
end
before do
allow(described_class).to receive(:loader_for).and_return(described_class::FormulaAPILoader.new(formula_name))
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
# don't try to load/fetch gcc/glibc
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)