From 38d28800bea8b49ec3b4430fa57fbc37317dbb6d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 20 Nov 2011 13:37:01 -0800 Subject: [PATCH] Destroy acceptance tests --- test/acceptance/destroy_test.rb | 24 ++++++++++++++++++++++++ test/acceptance/support/output.rb | 5 +++++ 2 files changed, 29 insertions(+) create mode 100644 test/acceptance/destroy_test.rb diff --git a/test/acceptance/destroy_test.rb b/test/acceptance/destroy_test.rb new file mode 100644 index 000000000..0b43136cc --- /dev/null +++ b/test/acceptance/destroy_test.rb @@ -0,0 +1,24 @@ +require File.expand_path("../base", __FILE__) +require "support/shared/command_examples" + +describe "vagrant destroy" do + include_context "acceptance" + it_behaves_like "a command that requires a Vagrantfile", ["vagrant", "destroy"] + it_behaves_like "a command that requires a virtual machine", ["vagrant", "destroy"] + + it "is able to destroy a running virtual machine" do + require_box("default") + + assert_execute("vagrant", "box", "add", "base", box_path("default")) + assert_execute("vagrant", "init") + assert_execute("vagrant", "up") + + # Destroy the VM and assert that it worked properly (seemingly) + result = assert_execute("vagrant", "destroy") + result.stdout.should match_output(:vm_destroyed) + + # Assert that the VM no longer is created + result = assert_execute("vagrant", "status") + result.stdout.should match_output(:status, "default", "not created") + end +end diff --git a/test/acceptance/support/output.rb b/test/acceptance/support/output.rb index 55d448a2b..bfcbc2284 100644 --- a/test/acceptance/support/output.rb +++ b/test/acceptance/support/output.rb @@ -50,5 +50,10 @@ module Acceptance def error_vm_must_be_created @text =~ /^VM must be created/ end + + # This checks that the VM is destroyed. + def vm_destroyed + @text =~ /Destroying VM and associated drives...$/ + end end end