Added `config.vm.define` which will be used for multi-VMs

This commit is contained in:
Mitchell Hashimoto 2010-05-07 21:19:11 -07:00
parent d7e0172e2d
commit 7419563b80
2 changed files with 27 additions and 6 deletions

View File

@ -125,6 +125,14 @@ module Vagrant
def customize(&block)
push_proc(&block)
end
def defined_vms
@defined_vms ||= {}
end
def define(name, &block)
defined_vms[name.to_sym] = block
end
end
class PackageConfig < Base

View File

@ -229,14 +229,27 @@ class ConfigTest < Test::Unit::TestCase
@env.config.ssh.username = @username
end
should "include the stacked proc runner module" do
assert @config.class.included_modules.include?(Vagrant::Util::StackedProcRunner)
context "defining VMs" do
should "store the proc by name but not run it" do
foo = mock("proc")
foo.expects(:call).never
proc = Proc.new { foo.call }
@config.define(:name, &proc)
assert_equal proc, @config.defined_vms[:name]
end
end
should "add the customize proc to the proc stack" do
proc = Proc.new {}
@config.customize(&proc)
assert_equal [proc], @config.proc_stack
context "customizing" do
should "include the stacked proc runner module" do
assert @config.class.included_modules.include?(Vagrant::Util::StackedProcRunner)
end
should "add the customize proc to the proc stack" do
proc = Proc.new {}
@config.customize(&proc)
assert_equal [proc], @config.proc_stack
end
end
context "uid/gid" do