Vagrant.config.home now returns nil if home is nil, otherwise expands path

This commit is contained in:
Mitchell Hashimoto 2010-03-13 01:53:12 -08:00
parent 98d8c1978b
commit 39a8a5fd94
2 changed files with 19 additions and 2 deletions

View File

@ -124,7 +124,7 @@ module Vagrant
attr_accessor :home attr_accessor :home
def home def home
File.expand_path(@home) @home ? File.expand_path(@home) : nil
end end
end end

View File

@ -8,7 +8,7 @@ class ConfigTest < Test::Unit::TestCase
assert Vagrant.config.ssh.private_key_path, 'success' assert Vagrant.config.ssh.private_key_path, 'success'
end end
end end
context "adding configures" do context "adding configures" do
should "forward the method to the Top class" do should "forward the method to the Top class" do
key = mock("key") key = mock("key")
@ -187,4 +187,21 @@ class ConfigTest < Test::Unit::TestCase
end end
end 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 end