Destroying properly updates the dotfile

This commit is contained in:
Mitchell Hashimoto 2010-05-16 18:01:53 -07:00
parent 07e1fb7238
commit 5be932bf6c
2 changed files with 10 additions and 8 deletions

View File

@ -5,17 +5,18 @@ module Vagrant
def execute!
@runner.invoke_around_callback(:destroy) do
destroy_vm
depersist
update_dotfile
end
end
def destroy_vm
logger.info "Destroying VM and associated drives..."
@runner.vm.destroy(:destroy_medium => :delete)
@runner.vm = nil
end
def depersist
@runner.env.depersist_vm
def update_dotfile
@runner.env.update_dotfile
end
end
end

View File

@ -15,7 +15,7 @@ class DestroyActionTest < Test::Unit::TestCase
@runner.stubs(:invoke_around_callback).yields
clear_seq = sequence("clear")
@action.expects(:destroy_vm).in_sequence(clear_seq)
@action.expects(:depersist).in_sequence(clear_seq)
@action.expects(:update_dotfile).in_sequence(clear_seq)
@action.execute!
end
end
@ -23,14 +23,15 @@ class DestroyActionTest < Test::Unit::TestCase
context "destroying the VM" do
should "destroy VM and attached images" do
@vm.expects(:destroy).with(:destroy_medium => :delete).once
@runner.expects(:vm=).with(nil).once
@action.destroy_vm
end
end
context "depersisting" do
should "call depersist_vm on Env" do
@runner.env.expects(:depersist_vm).once
@action.depersist
context "updating the dotfile" do
should "update the environment dotfile" do
@runner.env.expects(:update_dotfile).once
@action.update_dotfile
end
end
end