core: Fix Downloader tests

This commit is contained in:
Mitchell Hashimoto 2014-01-23 16:56:11 -08:00
parent c31feb0e94
commit 05eeefbe36
2 changed files with 20 additions and 1 deletions

View File

@ -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 = {}

View File

@ -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