diff --git a/Library/Homebrew/test/cask/cask_spec.rb b/Library/Homebrew/test/cask/cask_spec.rb index fea5589a37025..6558078ee0379 100644 --- a/Library/Homebrew/test/cask/cask_spec.rb +++ b/Library/Homebrew/test/cask/cask_spec.rb @@ -46,13 +46,15 @@ expect(c.token).to eq("caffeine") end - it "returns an instance of the Cask from a URL" do + it "returns an instance of the Cask from a URL", :needs_utils_curl do + expect(Homebrew::API).not_to receive(:fetch_json_api_file) c = Cask::CaskLoader.load("file://#{tap_path}/Casks/local-caffeine.rb") expect(c).to be_a(described_class) expect(c.token).to eq("local-caffeine") end - it "raises an error when failing to download a Cask from a URL" do + it "raises an error when failing to download a Cask from a URL", :needs_utils_curl do + expect(Homebrew::API).not_to receive(:fetch_json_api_file) expect do Cask::CaskLoader.load("file://#{tap_path}/Casks/notacask.rb") end.to raise_error(Cask::CaskUnavailableError) diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb index 86631a3a667dd..3bc5c5ee05427 100644 --- a/Library/Homebrew/test/formulary_spec.rb +++ b/Library/Homebrew/test/formulary_spec.rb @@ -119,7 +119,8 @@ class Wrong#{described_class.class_s(formula_name)} < Formula expect(described_class.factory(formula_path)).to be_a(Formula) end - it "returns a Formula when given a URL" do + it "returns a Formula when given a URL", :needs_utils_curl do + expect(Homebrew::API).not_to receive(:fetch_json_api_file) formula = described_class.factory("file://#{formula_path}") expect(formula).to be_a(Formula) end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index bb08dd6e5a661..47e5eff4016fc 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -165,6 +165,15 @@ skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"] end + config.before do |example| + next if example.metadata.key?(:needs_network) + next if example.metadata.key?(:needs_utils_curl) + + allow(Utils::Curl).to receive(:curl_executable).and_raise(<<~ERROR) + Unexpected call to Utils::Curl.curl_executable without setting :needs_network or :needs_utils_curl. + ERROR + end + config.before(:each, :needs_svn) do svn_shim = HOMEBREW_SHIMS_PATH/"shared/svn" skip "Subversion is not installed." unless quiet_system svn_shim, "--version"