Sha256: 7f465d439c52a35e01e33a9f7c6d1b57b0b0ef88256a80247865cd9bb615d88e

Contents?: true

Size: 1.71 KB

Versions: 24

Compression:

Stored size: 1.71 KB

Contents

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

describe "VagrantPlugins::GuestBSD::Cap::NFS" do
  let(:caps) do
    VagrantPlugins::GuestBSD::Plugin
      .components
      .guest_capabilities[:bsd]
  end

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

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

  after do
    comm.verify_expectations!
  end

  describe ".mount_nfs_folder" do
    let(:cap) { caps.get(:mount_nfs_folder) }
    let(:ip) { "1.2.3.4" }

    it "mounts the folder" do
      folders = {
        "/vagrant-nfs" => {
          guestpath: "/guest",
          hostpath: "/host",
        }
      }
      cap.mount_nfs_folder(machine, ip, folders)

      expect(comm.received_commands[0]).to match(/mkdir -p \/guest/)
      expect(comm.received_commands[1]).to match(/mount -t nfs/)
      expect(comm.received_commands[1]).to match(/1.2.3.4:\/host \/guest/)
    end

    it "mounts with options" do
      folders = {
        "/vagrant-nfs" => {
          guestpath: "/guest",
          hostpath: "/host",
          nfs_version: 2,
          nfs_udp: true,
          mount_options: ["banana"]
        }
      }
      cap.mount_nfs_folder(machine, ip, folders)

      expect(comm.received_commands[1]).to match(/mount -t nfs -o 'nfsv2,mntudp,banana'/)
    end

    it "escapes host and guest paths" do
      folders = {
        "/vagrant-nfs" => {
          guestpath: "/guest with spaces",
          hostpath: "/host's",
        }
      }
      cap.mount_nfs_folder(machine, ip, folders)

      expect(comm.received_commands[1]).to match(/host\\\'s/)
      expect(comm.received_commands[1]).to match(/guest\\\ with\\\ spaces/)
    end
  end
end

Version data entries

24 entries across 20 versions & 5 rubygems

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