From 7e9b75f93966cab1c7b25c88dedc845a7d37a7db Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 13 Jul 2010 20:30:24 -0700 Subject: [PATCH] Rescue TypeError when checking for NFS and return false [closes GH-109] --- lib/vagrant/hosts/bsd.rb | 2 ++ test/vagrant/hosts/bsd_test.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/vagrant/hosts/bsd.rb b/lib/vagrant/hosts/bsd.rb index 174273992..91e8afd95 100644 --- a/lib/vagrant/hosts/bsd.rb +++ b/lib/vagrant/hosts/bsd.rb @@ -7,6 +7,8 @@ module Vagrant def nfs? system("which nfsd") $?.to_i == 0 + rescue TypeError + false end def nfs_export(ip, folders) diff --git a/test/vagrant/hosts/bsd_test.rb b/test/vagrant/hosts/bsd_test.rb index 4d852cc69..df476de0c 100644 --- a/test/vagrant/hosts/bsd_test.rb +++ b/test/vagrant/hosts/bsd_test.rb @@ -26,6 +26,11 @@ class BSDHostTest < Test::Unit::TestCase assert !@instance.nfs? end + + should "not support NFS if an error is raised" do + @instance.expects(:system).raises(TypeError.new("foo")) + assert !@instance.nfs? + end end context "nfs export" do