Customize uses the proper VM object

This commit is contained in:
Mitchell Hashimoto 2010-07-07 09:15:30 -07:00
parent 6d4a23b6b8
commit 072e71df8a
3 changed files with 15 additions and 6 deletions

View File

@ -9,8 +9,8 @@ module Vagrant
def call(env) def call(env)
if !env.env.config.vm.proc_stack.empty? if !env.env.config.vm.proc_stack.empty?
env.logger.info "Running any VM customizations..." env.logger.info "Running any VM customizations..."
env.env.config.vm.run_procs!(env["vm"]) env.env.config.vm.run_procs!(env["vm"].vm)
env["vm"].save env["vm"].vm.save
end end
@app.call(env) @app.call(env)

View File

@ -8,18 +8,21 @@ class CustomizeVMActionTest < Test::Unit::TestCase
@vm = mock("vm") @vm = mock("vm")
@env["vm"] = @vm @env["vm"] = @vm
@internal_vm = mock("internal")
@vm.stubs(:vm).returns(@internal_vm)
end end
should "not run anything if no customize blocks exist" do should "not run anything if no customize blocks exist" do
@vm.expects(:save).never @internal_vm.expects(:save).never
@app.expects(:call).with(@env).once @app.expects(:call).with(@env).once
@instance.call(@env) @instance.call(@env)
end end
should "run the VM customization procs then save the VM" do should "run the VM customization procs then save the VM" do
@env.env.config.vm.customize { |vm| } @env.env.config.vm.customize { |vm| }
@env.env.config.vm.expects(:run_procs!).with(@vm) @env.env.config.vm.expects(:run_procs!).with(@internal_vm)
@vm.expects(:save).once @internal_vm.expects(:save).once
@app.expects(:call).with(@env).once @app.expects(:call).with(@env).once
@instance.call(@env) @instance.call(@env)
end end

View File

@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Mitchell Hashimoto", "John Bender"] s.authors = ["Mitchell Hashimoto", "John Bender"]
s.date = %q{2010-07-06} s.date = %q{2010-07-07}
s.default_executable = %q{vagrant} s.default_executable = %q{vagrant}
s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.} s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"] s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
@ -50,7 +50,9 @@ Gem::Specification.new do |s|
"lib/vagrant/action/vm/network.rb", "lib/vagrant/action/vm/network.rb",
"lib/vagrant/action/vm/persist.rb", "lib/vagrant/action/vm/persist.rb",
"lib/vagrant/action/vm/provision.rb", "lib/vagrant/action/vm/provision.rb",
"lib/vagrant/action/vm/resume.rb",
"lib/vagrant/action/vm/share_folders.rb", "lib/vagrant/action/vm/share_folders.rb",
"lib/vagrant/action/vm/suspend.rb",
"lib/vagrant/actions/base.rb", "lib/vagrant/actions/base.rb",
"lib/vagrant/actions/box/add.rb", "lib/vagrant/actions/box/add.rb",
"lib/vagrant/actions/box/destroy.rb", "lib/vagrant/actions/box/destroy.rb",
@ -146,7 +148,9 @@ Gem::Specification.new do |s|
"test/vagrant/action/vm/network_test.rb", "test/vagrant/action/vm/network_test.rb",
"test/vagrant/action/vm/persist_test.rb", "test/vagrant/action/vm/persist_test.rb",
"test/vagrant/action/vm/provision_test.rb", "test/vagrant/action/vm/provision_test.rb",
"test/vagrant/action/vm/resume_test.rb",
"test/vagrant/action/vm/share_folders_test.rb", "test/vagrant/action/vm/share_folders_test.rb",
"test/vagrant/action/vm/suspend_test.rb",
"test/vagrant/action_test.rb", "test/vagrant/action_test.rb",
"test/vagrant/actions/base_test.rb", "test/vagrant/actions/base_test.rb",
"test/vagrant/actions/box/add_test.rb", "test/vagrant/actions/box/add_test.rb",
@ -240,7 +244,9 @@ Gem::Specification.new do |s|
"test/vagrant/action/vm/network_test.rb", "test/vagrant/action/vm/network_test.rb",
"test/vagrant/action/vm/persist_test.rb", "test/vagrant/action/vm/persist_test.rb",
"test/vagrant/action/vm/provision_test.rb", "test/vagrant/action/vm/provision_test.rb",
"test/vagrant/action/vm/resume_test.rb",
"test/vagrant/action/vm/share_folders_test.rb", "test/vagrant/action/vm/share_folders_test.rb",
"test/vagrant/action/vm/suspend_test.rb",
"test/vagrant/action_test.rb", "test/vagrant/action_test.rb",
"test/vagrant/actions/base_test.rb", "test/vagrant/actions/base_test.rb",
"test/vagrant/actions/box/add_test.rb", "test/vagrant/actions/box/add_test.rb",