From 35a19f829c67b55c28837f13fe8dacdedf1cf039 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 15 Jan 2014 11:48:07 -0800 Subject: [PATCH] provider/virtualbox: fix NFS tests on Windows --- lib/vagrant/util/platform.rb | 2 +- .../action/prepare_nfs_settings_test.rb | 37 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 489ef63ff..1ebc08f71 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -58,7 +58,7 @@ module Vagrant # This expands the path and ensures proper casing of each part # of the path. - def fs_real_path(path) + def fs_real_path(path, **opts) path = Pathname.new(File.expand_path(path)) if path.exist? && !fs_case_sensitive? diff --git a/test/unit/plugins/providers/virtualbox/action/prepare_nfs_settings_test.rb b/test/unit/plugins/providers/virtualbox/action/prepare_nfs_settings_test.rb index 4751c083e..8ce3c603b 100644 --- a/test/unit/plugins/providers/virtualbox/action/prepare_nfs_settings_test.rb +++ b/test/unit/plugins/providers/virtualbox/action/prepare_nfs_settings_test.rb @@ -1,31 +1,27 @@ require_relative "../base" +require "vagrant/util/platform" + describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do include_context "unit" include_context "virtualbox" - let(:machine) { - environment = Vagrant::Environment.new - provider = :virtualbox - provider_cls, provider_options = Vagrant.plugin("2").manager.providers[provider] - provider_config = Vagrant.plugin("2").manager.provider_configs[provider] + let(:iso_env) do + # We have to create a Vagrantfile so there is a root path + env = isolated_environment + env.vagrantfile("") + env.create_vagrant_env + end - Vagrant::Machine.new( - 'test_machine', - provider, - provider_cls, - provider_config, - provider_options, - environment.config_global, - Pathname('data_dir'), - double('box'), - environment - ) - } + let(:machine) do + iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m| + m.provider.stub(driver: driver) + end + end let(:env) {{ machine: machine }} let(:app) { lambda { |*args| }} - let(:driver) { env[:machine].provider.driver } + let(:driver) { double("driver") } subject { described_class.new(app, env) } @@ -41,7 +37,10 @@ describe VagrantPlugins::ProviderVirtualBox::Action::PrepareNFSSettings do context "with an nfs synced folder" do before do - env[:machine].config.vm.synced_folder("/host/path", "/guest/path", nfs: true) + # We can't be on Windows, because NFS gets disabled on Windows + Vagrant::Util::Platform.stub(windows?: false) + + env[:machine].config.vm.synced_folder("/host/path", "/guest/path", type: "nfs") env[:machine].config.finalize! # Stub out the stuff so it just works by default