Default include files to empty array

This commit is contained in:
Mitchell Hashimoto 2010-02-28 00:03:21 -08:00
parent 79718eb4c3
commit f316e0c61c
2 changed files with 24 additions and 5 deletions

View File

@ -6,10 +6,10 @@ module Vagrant
attr_accessor :include_files
attr_accessor :temp_path
def initialize(vm, out_path = nil, include_files = [], *args)
def initialize(vm, out_path = nil, include_files = nil, *args)
super
@out_path = out_path || "package"
@include_files = include_files
@include_files = include_files || []
@temp_path = nil
end
@ -31,11 +31,12 @@ module Vagrant
logger.info "Packaging VM into #{tar_path} ..."
Tar.open(tar_path, File::CREAT | File::WRONLY, 0644, Tar::GNU) do |tar|
begin
current_dir = FileUtils.pwd
@include_files.each { |f| tar.append_file(f) }
# Append tree will append the entire directory tree unless a relative folder reference is used
current_dir = FileUtils.pwd
FileUtils.cd(temp_path)
# Append tree will append the entire directory tree unless a relative folder reference is used
tar.append_tree(".")
ensure
FileUtils.cd(current_dir)

View File

@ -9,6 +9,24 @@ class PackageActionTest < Test::Unit::TestCase
@action.temp_path = @temp_path
end
context "initialization" do
def get_action(*args)
wrapper_vm, vm, action = mock_action(Vagrant::Actions::VM::Package, *args)
return action
end
should "make out_path 'package' by default if nil is given" do
action = get_action(nil, [])
assert_equal "package", @action.out_path
end
should "make include files an empty array by default" do
action = get_action("foo", nil)
assert action.include_files.is_a?(Array)
assert action.include_files.empty?
end
end
context "executing" do
setup do
@action.stubs(:compress)
@ -97,7 +115,7 @@ class PackageActionTest < Test::Unit::TestCase
@action.compress
end
end
context "export callback to set temp path" do
should "save to the temp_path directory" do
foo = mock("foo")