diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index 65ba6c5bc..0f7e6b19f 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -29,9 +29,9 @@ module Vagrant def instantiate_downloader @env["download.classes"].each do |klass| - if klass.match?(@env["download.uri"]) + if klass.match?(@env["box"].uri) @env.logger.info "Downloading with #{klass}..." - @downloader = klass.new(@env["download.uri"]) + @downloader = klass.new(@env["box"].uri) end end @@ -40,7 +40,7 @@ module Vagrant return false end - @downloader.prepare(@env["download.uri"]) + @downloader.prepare(@env["box"].uri) true end @@ -71,7 +71,7 @@ module Vagrant def download_to(f) @env.logger.info "Copying box to temporary location..." - @downloader.download!(@env["download.uri"], f) + @downloader.download!(@env["box"].uri, f) end end end diff --git a/test/vagrant/action/box/download_test.rb b/test/vagrant/action/box/download_test.rb index 34adae6a7..3b3a3b862 100644 --- a/test/vagrant/action/box/download_test.rb +++ b/test/vagrant/action/box/download_test.rb @@ -7,6 +7,8 @@ class DownloadBoxActionTest < Test::Unit::TestCase @vm = mock("vm") @env["vm"] = @vm + @env["box"] = Vagrant::Box.new(mock_environment, "foo") + @env["box"].uri = "http://google.com" @internal_vm = mock("internal") @vm.stubs(:vm).returns(@internal_vm) @@ -22,7 +24,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase context "with an instance" do setup do @instance = @klass.new(@app, @env) - @env["download.uri"] = "http://google.com" end context "calling" do @@ -48,13 +49,13 @@ class DownloadBoxActionTest < Test::Unit::TestCase context "instantiating downloader" do should "instantiate the proper class" do instance = mock("instance") - Vagrant::Downloaders::HTTP.expects(:new).with(@env["download.uri"]).returns(instance) - instance.expects(:prepare).with(@env["download.uri"]).once + Vagrant::Downloaders::HTTP.expects(:new).with(@env["box"].uri).returns(instance) + instance.expects(:prepare).with(@env["box"].uri).once assert @instance.instantiate_downloader end should "error environment if URI is invalid for any downloaders" do - @env["download.uri"] = "foobar" + @env["box"].uri = "foobar" assert !@instance.instantiate_downloader assert @env.error? assert_equal :box_download_unknown_type, @env.error.first @@ -131,7 +132,7 @@ class DownloadBoxActionTest < Test::Unit::TestCase should "call download! on the download with the URI and tempfile" do tempfile = "foo" - @downloader.expects(:download!).with(@env["download.uri"], tempfile) + @downloader.expects(:download!).with(@env["box"].uri, tempfile) @instance.download_to(tempfile) end end