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) def customize(&block)
push_proc(&block) push_proc(&block)
end end
def defined_vms
@defined_vms ||= {}
end
def define(name, &block)
defined_vms[name.to_sym] = block
end
end end
class PackageConfig < Base class PackageConfig < Base

View File

@ -229,14 +229,27 @@ class ConfigTest < Test::Unit::TestCase
@env.config.ssh.username = @username @env.config.ssh.username = @username
end end
should "include the stacked proc runner module" do context "defining VMs" do
assert @config.class.included_modules.include?(Vagrant::Util::StackedProcRunner) 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 end
should "add the customize proc to the proc stack" do context "customizing" do
proc = Proc.new {} should "include the stacked proc runner module" do
@config.customize(&proc) assert @config.class.included_modules.include?(Vagrant::Util::StackedProcRunner)
assert_equal [proc], @config.proc_stack 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 end
context "uid/gid" do context "uid/gid" do