Sha256: e6084d1683cb8a63ef14e7c7747a0acfb56a9837fe5e69793a74c1bb7b301f21

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require "test_helper"

class ClearSharedFoldersVMActionTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Action::VM::ClearSharedFolders
    @app, @env = mock_action_data

    @vm = mock("vm")
    @env["vm"] = @vm

    @internal_vm = mock("internal")
    @vm.stubs(:vm).returns(@internal_vm)

    @instance = @klass.new(@app, @env)
  end

  context "calling" do
    should "call the proper methods in sequence" do
      seq = sequence("seq")
      @instance.expects(:clear_shared_folders).once.in_sequence(seq)
      @app.expects(:call).with(@env).once
      @instance.call(@env)
    end
  end

  context "clearing shared folders" do
    setup do
      @shared_folder = mock("shared_folder")
      @shared_folders = [@shared_folder]
      @internal_vm.stubs(:shared_folders).returns(@shared_folders)
    end

    should "call destroy on each shared folder then reload" do
      destroy_seq = sequence("destroy")
      @shared_folders.each do |sf|
        sf.expects(:destroy).once.in_sequence(destroy_seq)
      end

      @vm.expects(:reload!).once.in_sequence(destroy_seq)
      @instance.clear_shared_folders
    end

    should "do nothing if no shared folders existed" do
      @shared_folders.clear
      @vm.expects(:reload!).never
      @instance.clear_shared_folders
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrantup-0.5.4 test/vagrant/action/vm/clear_shared_folders_test.rb
vagrantup-0.5.3 test/vagrant/action/vm/clear_shared_folders_test.rb
vagrant-0.5.4 test/vagrant/action/vm/clear_shared_folders_test.rb
vagrant-0.5.3 test/vagrant/action/vm/clear_shared_folders_test.rb