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! def execute!
@runner.invoke_around_callback(:destroy) do @runner.invoke_around_callback(:destroy) do
destroy_vm destroy_vm
depersist update_dotfile
end end
end end
def destroy_vm def destroy_vm
logger.info "Destroying VM and associated drives..." logger.info "Destroying VM and associated drives..."
@runner.vm.destroy(:destroy_medium => :delete) @runner.vm.destroy(:destroy_medium => :delete)
@runner.vm = nil
end end
def depersist def update_dotfile
@runner.env.depersist_vm @runner.env.update_dotfile
end end
end end
end end

View File

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