diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index adde686a3..91843995c 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -41,6 +41,7 @@ module Vagrant @app.call(env) mount_folders if !folders.empty? && !env.error? + clear_nfs_exports(env) if env.error? end # Returns the folders which are to be synced via NFS. diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index 65bd372e2..e457d7418 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -37,7 +37,7 @@ class NFSVMActionTest < Test::Unit::TestCase setup do @instance.stubs(:folders).returns([:a]) - [:extract_folders, :export_folders, :mount_folders].each do |meth| + [:clear_nfs_exports, :extract_folders, :export_folders, :mount_folders].each do |meth| @instance.stubs(meth) end end @@ -76,13 +76,16 @@ class NFSVMActionTest < Test::Unit::TestCase end should "not mount folders if an error occured" do - @app.expects(:call).with() do + seq = sequence("seq") + @app.expects(:call).in_sequence(seq).with() do # Use this mark the env as error @env.error!(:foo) true end + @instance.expects(:clear_nfs_exports).with(@env).in_sequence(seq) + @instance.expects(:mount_folders).never @instance.call(@env) end