Sha256: 8d1426ddf976de357ce3aff7e0eb2a230daa819a6ce8b8e844def6688d2cbfa9

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')

class DownActionTest < Test::Unit::TestCase
  setup do
    @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Down)
  end

  context "preparing" do
    setup do
      @vm.stubs(:running?).returns(false)
    end

    def setup_action_expectations(order)
      default_seq = sequence("default_seq")
      order.each do |action|
        action = [action] unless action.is_a?(Array)
        @runner.expects(:add_action).with(action.shift, *action).once.in_sequence(default_seq)
      end
    end

    should "add the destroy action alone if VM is not running" do
      setup_action_expectations([Vagrant::Actions::VM::Network, Vagrant::Actions::VM::Destroy])
      @action.prepare
    end

    should "add the halt action if the VM is running" do
      @vm.expects(:running?).returns(true)
      setup_action_expectations([[Vagrant::Actions::VM::Halt, {:force => true}], Vagrant::Actions::VM::Network, Vagrant::Actions::VM::Destroy])
      @action.prepare
    end
  end

  context "after halting" do
    should "sleep" do
      Kernel.expects(:sleep).once
      @action.after_halt
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrantup-0.4.3.dev test/vagrant/actions/vm/down_test.rb
vagrantup-0.4.1 test/vagrant/actions/vm/down_test.rb
vagrantup-0.4.0 test/vagrant/actions/vm/down_test.rb
vagrant-0.4.2 test/vagrant/actions/vm/down_test.rb
vagrant-0.4.1 test/vagrant/actions/vm/down_test.rb
vagrant-0.4.0 test/vagrant/actions/vm/down_test.rb