fix for no extract results from uri check

This commit is contained in:
John Bender 2010-03-23 00:03:28 -07:00
parent 2067f000f5
commit 527e101cab
4 changed files with 9 additions and 3 deletions

View File

@ -48,7 +48,7 @@ module Vagrant
def with_tempfile
logger.info "Creating tempfile for storing box file..."
# create, write only, fail if the file exists
# create, write only, fail if the file exists
File.open(box_temp_path, File::WRONLY|File::EXCL|File::CREAT) do |tempfile|
yield tempfile
end

View File

@ -8,7 +8,8 @@ module Vagrant
def self.match?(uri)
# URI.parse barfs on '<drive letter>:\\files \on\ windows'
URI.extract(uri).first.include?(uri)
uri = URI.extract(uri).first
uri && uri.include?(uri)
end
def download!(source_url, destination_file)

View File

@ -89,7 +89,7 @@ class DownloadBoxActionTest < Test::Unit::TestCase
context "tempfile" do
should "create a tempfile in the vagrant tmp directory" do
File.expects(:open).with { |name, bitmask|
name =~ /#{Vagrant::Actions::Box::Download::BASENAME}/ && name =~ /#{@runner.env.tmp_path}/
name =~ /#{Vagrant::Actions::Box::Download::BASENAME}/ && name =~ /#{@runner.env.tmp_path}/
}.once
@action.with_tempfile
end

View File

@ -39,6 +39,11 @@ class HttpDownloaderTest < Test::Unit::TestCase
URI.expects(:extract).returns(['foo'])
assert Vagrant::Downloaders::HTTP.match?('foo')
end
should "return false if there are no extract results" do
URI.expects(:extract).returns([])
assert !Vagrant::Downloaders::HTTP.match?('foo')
end
end
context "reporting progress" do