Skip to content

Commit e5fefd7

Browse files
Merge pull request #16697 from apainintheneck/update-some-formulary-specs
formulary_spec: update API tests to avoid mocking
2 parents 5d3fae3 + e96313f commit e5fefd7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Library/Homebrew/tap.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,8 @@ def formula_files_by_name
11691169
name, formula_hash = item
11701170
# If there's more than one item with the same path: use the longer one to prioritise more specific results.
11711171
existing_path = hash[name]
1172-
new_path = File.join(tap_path, formula_hash["ruby_source_path"]) # Pathname equivalent is slow in a tight loop
1172+
# Pathname equivalent is slow in a tight loop
1173+
new_path = File.join(tap_path, formula_hash.fetch("ruby_source_path"))
11731174
hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length
11741175
end
11751176
end

Library/Homebrew/test/formulary_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ class Wrong#{described_class.class_s(formula_name)} < Formula
158158

159159
context "with installed Formula" do
160160
before do
161-
allow(described_class).to receive(:loader_for).and_call_original
162-
163161
# don't try to load/fetch gcc/glibc
164162
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
165163
end
@@ -329,6 +327,7 @@ def formula_json_contents(extra_items = {})
329327
"run_type" => "immediate",
330328
"working_dir" => "/$HOME",
331329
},
330+
"ruby_source_path" => "Formula/#{formula_name}.rb",
332331
}.merge(extra_items),
333332
}
334333
end
@@ -378,7 +377,7 @@ def formula_json_contents(extra_items = {})
378377
end
379378

380379
before do
381-
allow(described_class).to receive(:loader_for).and_return(described_class::FormulaAPILoader.new(formula_name))
380+
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
382381

383382
# don't try to load/fetch gcc/glibc
384383
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)

0 commit comments

Comments
 (0)