Destroy subcommand
This commit is contained in:
parent
60c6ad480c
commit
33c3a2df45
|
@ -0,0 +1,17 @@
|
|||
module Vagrant
|
||||
class Commands
|
||||
class Destroy < Base
|
||||
Base.subcommand "destroy", self
|
||||
description "Destroys the vagrant environment"
|
||||
|
||||
def execute(args=[])
|
||||
env.require_persisted_vm
|
||||
env.vm.destroy
|
||||
end
|
||||
|
||||
def options_spec(opts)
|
||||
opts.banner = "Usage: vagrant destroy"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||
|
||||
class CommandsDestroyTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Commands::Destroy
|
||||
|
||||
@persisted_vm = mock("persisted_vm")
|
||||
@persisted_vm.stubs(:execute!)
|
||||
|
||||
@env = mock_environment
|
||||
@env.stubs(:require_persisted_vm)
|
||||
@env.stubs(:vm).returns(@persisted_vm)
|
||||
|
||||
@instance = @klass.new(@env)
|
||||
end
|
||||
|
||||
context "executing" do
|
||||
setup do
|
||||
@persisted_vm.stubs(:destroy)
|
||||
end
|
||||
|
||||
should "require a persisted VM" do
|
||||
@env.expects(:require_persisted_vm).once
|
||||
@instance.execute
|
||||
end
|
||||
|
||||
should "destroy the persisted VM and the VM image" do
|
||||
@persisted_vm.expects(:destroy).once
|
||||
@instance.execute
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue