diff --git a/Library/Homebrew/test/utils/git_spec.rb b/Library/Homebrew/test/utils/git_spec.rb index 238f580277..32d2749f52 100644 --- a/Library/Homebrew/test/utils/git_spec.rb +++ b/Library/Homebrew/test/utils/git_spec.rb @@ -186,7 +186,10 @@ RSpec.describe Utils::Git do unless ENV["HOMEBREW_TEST_GENERIC_OS"] it "installs git" do expect(described_class).to receive(:available?).and_return(false) - allow_any_instance_of(Formula).to receive(:ensure_installed!) + allow(CoreTap.instance).to receive(:installed?).and_return(true) + formula_double = instance_double(Formula) + allow(Formula).to receive(:[]).with("git").and_return(formula_double) + allow(formula_double).to receive(:ensure_installed!).and_return(formula_double) expect(described_class).to receive(:available?).and_return(true) described_class.ensure_installed!