Sha256: fe0a095b642552164cca42908716149259ad75fb396b63e1a6fdfbda6ea1e434

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require_relative "../../../../base"

describe "VagrantPlugins::GuestNetBSD::Cap::ShellExpandGuestPath" do
  let(:caps) do
    VagrantPlugins::GuestNetBSD::Plugin
      .components
      .guest_capabilities[:netbsd]
  end

  let(:machine) { double("machine") }
  let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }

  before do
    allow(machine).to receive(:communicate).and_return(comm)
  end

  describe "#shell_expand_guest_path" do
    let(:cap) { caps.get(:shell_expand_guest_path) }

    it "expands the path" do
      path = "/home/vagrant/folder"
      allow(machine.communicate).to receive(:execute).
        with(any_args).and_yield(:stdout, "/home/vagrant/folder")

      cap.shell_expand_guest_path(machine, path)
    end

    it "raises an exception if no path was detected" do
      path = "/home/vagrant/folder"
      expect { cap.shell_expand_guest_path(machine, path) }.
        to raise_error(Vagrant::Errors::ShellExpandFailed)
    end

    it "returns a path with a space in it" do
      path = "/home/vagrant folder/folder"
      allow(machine.communicate).to receive(:execute).
        with(any_args).and_yield(:stdout, "/home/vagrant folder/folder")

      expect(machine.communicate).to receive(:execute).with("printf \"#{path}\"")
      cap.shell_expand_guest_path(machine, path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-unbundled-1.9.8.1 test/unit/plugins/guests/netbsd/cap/shell_expand_guest_path_test.rb