diff --git a/lib/vagrant/hosts/bsd.rb b/lib/vagrant/hosts/bsd.rb index 21d91f301..18933aaef 100644 --- a/lib/vagrant/hosts/bsd.rb +++ b/lib/vagrant/hosts/bsd.rb @@ -5,10 +5,16 @@ module Vagrant include Util def nfs? - system("which nfsd > /dev/null 2>&1") - $?.to_i == 0 - rescue TypeError - false + tries = 10 + begin + system("which nfsd > /dev/null 2>&1") + rescue TypeError + tries -= 1 + retry if tries > 0 + + # Hopefully this point isn't reached + raise + end end def nfs_export(ip, folders) diff --git a/test/vagrant/hosts/bsd_test.rb b/test/vagrant/hosts/bsd_test.rb index b79f93cab..4cb087997 100644 --- a/test/vagrant/hosts/bsd_test.rb +++ b/test/vagrant/hosts/bsd_test.rb @@ -12,26 +12,20 @@ class BSDHostTest < Test::Unit::TestCase context "supporting nfs check" do should "support NFS" do - @instance.expects(:system).with() do |cmd| - `which which` - true - end - + @instance.expects(:system).returns(true) assert @instance.nfs? end should "not support NFS if nfsd is not found" do - @instance.expects(:system).with() do |cmd| - `which thisshouldnoteverneverexist` - true - end - + @instance.expects(:system).returns(false) assert !@instance.nfs? end - should "not support NFS if an error is raised" do - @instance.expects(:system).raises(TypeError.new("foo")) - assert !@instance.nfs? + should "retry until a boolean is returned" do + seq = sequence("seq") + @instance.expects(:system).in_sequence(seq).raises(TypeError.new("foo")) + @instance.expects(:system).in_sequence(seq).returns(true) + assert @instance.nfs? end end diff --git a/vagrant.gemspec b/vagrant.gemspec index cafe8dbe8..f1641c640 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.authors = ["Mitchell Hashimoto", "John Bender"] - s.date = %q{2010-07-15} + s.date = %q{2010-07-16} s.default_executable = %q{vagrant} s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.} s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]