`vagrant reload` uses new Environment

This commit is contained in:
Mitchell Hashimoto 2010-03-19 16:50:54 -07:00
parent b461e0ee8b
commit e68994556c
4 changed files with 14 additions and 7 deletions

View File

@ -5,7 +5,7 @@ module Vagrant
def prepare def prepare
steps = [Customize, ForwardPorts, SharedFolders, Boot] steps = [Customize, ForwardPorts, SharedFolders, Boot]
steps.unshift(Halt) if @runner.vm.running? steps.unshift(Halt) if @runner.vm.running?
steps << Provision if !Vagrant.config.vm.provisioner.nil? steps << Provision if !@runner.env.config.vm.provisioner.nil?
steps.each do |action_klass| steps.each do |action_klass|
@runner.add_action(action_klass) @runner.add_action(action_klass)

View File

@ -101,9 +101,9 @@ msg
# VM, updates the metadata (shared folders, forwarded ports), restarts # VM, updates the metadata (shared folders, forwarded ports), restarts
# the VM, and then reruns the provisioning if enabled. # the VM, and then reruns the provisioning if enabled.
def reload def reload
Env.load! env = Environment.load!
Env.require_persisted_vm env.require_persisted_vm
Env.persisted_vm.execute!(Actions::VM::Reload) env.vm.execute!(Actions::VM::Reload)
end end
# SSH into the vagrant instance. This will setup an SSH connection into # SSH into the vagrant instance. This will setup an SSH connection into

View File

@ -32,11 +32,13 @@ class ReloadActionTest < Test::Unit::TestCase
end end
should "add in the provisioning step if enabled" do should "add in the provisioning step if enabled" do
mock_config do |config| env = mock_environment do |config|
# Dummy provisioner to test # Dummy provisioner to test
config.vm.provisioner = "foo" config.vm.provisioner = "foo"
end end
@runner.stubs(:env).returns(env)
@default_order.push(Vagrant::Actions::VM::Provision) @default_order.push(Vagrant::Actions::VM::Provision)
setup_action_expectations setup_action_expectations
@action.prepare @action.prepare

View File

@ -107,8 +107,13 @@ class CommandsTest < Test::Unit::TestCase
end end
context "reload" do context "reload" do
should "load the current environment" do
Vagrant::Environment.expects(:load!).once.returns(@env)
Vagrant::Commands.reload
end
should "require a persisted VM" do should "require a persisted VM" do
Vagrant::Env.expects(:require_persisted_vm).once @env.expects(:require_persisted_vm).once
Vagrant::Commands.reload Vagrant::Commands.reload
end end