Sha256: 5ea5bec016196b985c6fd325039261be840c543a8d7a5585314c0284ee1c8424

Contents?: true

Size: 1.36 KB

Versions: 16

Compression:

Stored size: 1.36 KB

Contents

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

describe "VagrantPlugins::GuestDarwin::Cap::ShellExpandGuestPath" do
  let(:caps) do
    VagrantPlugins::GuestDarwin::Plugin
      .components
      .guest_capabilities[:darwin]
  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"
      path_with_spaces = "/home/vagrant\\ folder/folder"
      allow(machine.communicate).to receive(:execute).
        with(any_args).and_yield(:stdout, path_with_spaces)

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

Version data entries

16 entries across 12 versions & 5 rubygems

Version Path
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-unbundled-2.0.2.0 test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-unbundled-2.0.1.0 test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb
vagrant-unbundled-2.0.0.1 test/unit/plugins/guests/darwin/cap/shell_expand_guest_path_test.rb