Tab => Spaces

This commit is contained in:
Mitchell Hashimoto 2010-03-22 00:13:48 -07:00
parent bfcc0d3939
commit c25ff5300a
3 changed files with 12 additions and 11 deletions

View File

@ -51,15 +51,16 @@ module Vagrant
def with_tempfile def with_tempfile
logger.info "Creating tempfile for storing box file..." logger.info "Creating tempfile for storing box file..."
# create, write only, fail if the file exists
File.open(file_temp_path, File::WRONLY|File::EXCL|File::CREAT) do |tempfile| # create, write only, fail if the file exists
yield tempfile File.open(file_temp_path, File::WRONLY | File::EXCL | File::CREAT) do |tempfile|
yield tempfile
end end
end end
def file_temp_path def file_temp_path
File.join(@runner.env.tmp_path, BASENAME + Time.now.to_i.to_s) File.join(@runner.env.tmp_path, BASENAME + Time.now.to_i.to_s)
end end
def download_to(f) def download_to(f)
logger.info "Copying box to temporary location..." logger.info "Copying box to temporary location..."

View File

@ -82,7 +82,7 @@ class DownloadBoxActionTest < Test::Unit::TestCase
context "tempfile" do context "tempfile" do
should "create a tempfile in the vagrant tmp directory" do should "create a tempfile in the vagrant tmp directory" do
File.expects(:open).with { |name, bitmask| 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 }.once
@action.with_tempfile @action.with_tempfile
end end

View File

@ -153,13 +153,13 @@ class EnvironmentTest < Test::Unit::TestCase
context "loading the root path" do context "loading the root path" do
setup do setup do
@env.cwd = "/foo" @env.cwd = "/foo"
end end
should "default the path to the cwd instance var if nil" do should "default the path to the cwd instance var if nil" do
@path = mock("path") @path = mock("path")
@path.stubs(:root?).returns(true) @path.stubs(:root?).returns(true)
File.expects(:expand_path).with(@env.cwd).returns(@env.cwd) File.expects(:expand_path).with(@env.cwd).returns(@env.cwd)
Pathname.expects(:new).with(@env.cwd).returns(@path) Pathname.expects(:new).with(@env.cwd).returns(@path)
@env.load_root_path!(nil) @env.load_root_path!(nil)
end end
@ -182,7 +182,7 @@ class EnvironmentTest < Test::Unit::TestCase
search_seq = sequence("search_seq") search_seq = sequence("search_seq")
paths.each do |path| paths.each do |path|
# NOTE File.expect(:expand_path) causes tests to hang in windows below is the interim solution # NOTE File.expect(:expand_path) causes tests to hang in windows below is the interim solution
File.expects(:exist?).with("#{File.expand_path(path)}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(false).in_sequence(search_seq) File.expects(:exist?).with("#{File.expand_path(path)}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(false).in_sequence(search_seq)
end end
@ -205,7 +205,7 @@ class EnvironmentTest < Test::Unit::TestCase
end end
should "should set the path for the rootfile" do should "should set the path for the rootfile" do
# NOTE File.expect(:expand_path) causes tests to hang in windows below is the interim solution # NOTE File.expect(:expand_path) causes tests to hang in windows below is the interim solution
path = File.expand_path("/foo") path = File.expand_path("/foo")
File.expects(:exist?).with("#{path}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(true) File.expects(:exist?).with("#{path}/#{Vagrant::Environment::ROOTFILE_NAME}").returns(true)