From 39a8a5fd94cf6c2beb2c8befa443d43aa0c4bf87 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 13 Mar 2010 01:53:12 -0800 Subject: [PATCH] Vagrant.config.home now returns nil if home is nil, otherwise expands path --- lib/vagrant/config.rb | 2 +- test/vagrant/config_test.rb | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/config.rb b/lib/vagrant/config.rb index c64b25c5f..1939fb25f 100644 --- a/lib/vagrant/config.rb +++ b/lib/vagrant/config.rb @@ -124,7 +124,7 @@ module Vagrant attr_accessor :home def home - File.expand_path(@home) + @home ? File.expand_path(@home) : nil end end diff --git a/test/vagrant/config_test.rb b/test/vagrant/config_test.rb index 83509b59b..a301b0875 100644 --- a/test/vagrant/config_test.rb +++ b/test/vagrant/config_test.rb @@ -8,7 +8,7 @@ class ConfigTest < Test::Unit::TestCase assert Vagrant.config.ssh.private_key_path, 'success' end end - + context "adding configures" do should "forward the method to the Top class" do key = mock("key") @@ -187,4 +187,21 @@ class ConfigTest < Test::Unit::TestCase end end end + + context "vagrant configuration" do + setup do + @config = Vagrant::Config::VagrantConfig.new + end + + should "return nil if home is nil" do + File.expects(:expand_path).never + assert @config.home.nil? + end + + should "expand the path if home is not nil" do + @config.home = "foo" + File.expects(:expand_path).with("foo").once.returns("result") + assert_equal "result", @config.home + end + end end