From 05eeefbe36e28b672dd9720002d3c96d3f0c6e67 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Jan 2014 16:56:11 -0800 Subject: [PATCH] core: Fix Downloader tests --- lib/vagrant/util/downloader.rb | 3 ++- test/unit/vagrant/util/downloader_test.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/downloader.rb b/lib/vagrant/util/downloader.rb index 64028b18e..3858936db 100644 --- a/lib/vagrant/util/downloader.rb +++ b/lib/vagrant/util/downloader.rb @@ -40,6 +40,7 @@ module Vagrant def download! options, subprocess_options = self.options options += ["--output", @destination] + options << @source # This variable can contain the proc that'll be sent to # the subprocess execute. @@ -122,6 +123,7 @@ module Vagrant def head options, subprocess_options = self.options options.unshift("-I") + options << @source @logger.info("HEAD: #{@source}") result = execute_curl(options, subprocess_options) @@ -177,7 +179,6 @@ module Vagrant options += ["--continue-at", "-"] if @continue options << "--insecure" if @insecure options << "--cert" << @client_cert if @client_cert - options << @source # Specify some options for the subprocess subprocess_options = {} diff --git a/test/unit/vagrant/util/downloader_test.rb b/test/unit/vagrant/util/downloader_test.rb index 1f73d57b8..6be2ee7f9 100644 --- a/test/unit/vagrant/util/downloader_test.rb +++ b/test/unit/vagrant/util/downloader_test.rb @@ -54,4 +54,22 @@ describe Vagrant::Util::Downloader do pending "tests for a UI" end end + + describe "#head" do + let(:curl_options) { + ["--fail", "--location", "--max-redirs", "10", "--user-agent", described_class::USER_AGENT, source, {}] + } + + it "returns the output" do + subprocess_result.stub(stdout: "foo") + + options = curl_options.dup + options.unshift("-I") + + Vagrant::Util::Subprocess.should_receive(:execute). + with("curl", *options).and_return(subprocess_result) + + expect(subject.head).to eq("foo") + end + end end