vagrant-reload works

This commit is contained in:
Mitchell Hashimoto 2010-02-16 15:48:03 -08:00
parent e8e07d26f5
commit e855ae9965
4 changed files with 40 additions and 3 deletions

View File

@ -1,6 +1,14 @@
module Vagrant
module Actions
class Reload < Base
def prepare
steps = [Stop, ForwardPorts, SharedFolders, Start]
steps << Provision if Vagrant.config.chef.enabled
steps.each do |action_klass|
@vm.add_action(action_klass)
end
end
end
end
end

View File

@ -63,8 +63,7 @@ error
def reload
Env.load!
Env.require_persisted_vm
VM.execute!(Actions::Reload)
Env.persisted_vm.execute!(Actions::Reload)
end
# SSH into the vagrant instance. This will setup an SSH connection into

View File

@ -3,5 +3,34 @@ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
class ReloadActionTest < Test::Unit::TestCase
setup do
@mock_vm, @vm, @action = mock_action(Vagrant::Actions::Reload)
mock_config
end
context "sub-actions" do
setup do
@default_order = [Vagrant::Actions::Stop, Vagrant::Actions::ForwardPorts, Vagrant::Actions::SharedFolders, Vagrant::Actions::Start]
end
def setup_action_expectations
default_seq = sequence("default_seq")
@default_order.each do |action|
@mock_vm.expects(:add_action).with(action).once.in_sequence(default_seq)
end
end
should "do the proper actions by default" do
setup_action_expectations
@action.prepare
end
should "add in the provisioning step if enabled" do
mock_config do |config|
config.chef.enabled = true
end
@default_order.push(Vagrant::Actions::Provision)
setup_action_expectations
@action.prepare
end
end
end

View File

@ -5,6 +5,7 @@ class CommandsTest < Test::Unit::TestCase
Vagrant::Env.stubs(:load!)
@persisted_vm = mock("persisted_vm")
@persisted_vm.stubs(:execute!)
Vagrant::Env.stubs(:persisted_vm).returns(@persisted_vm)
end
@ -75,7 +76,7 @@ class CommandsTest < Test::Unit::TestCase
end
should "call the `reload` action on the VM" do
Vagrant::VM.expects(:execute!).with(Vagrant::Actions::Reload).once
@persisted_vm.expects(:execute!).with(Vagrant::Actions::Reload).once
Vagrant::Commands.reload
end
end