Set the environment on the loaded box

This commit is contained in:
Mitchell Hashimoto 2010-03-19 15:53:24 -07:00
parent a2a59b532b
commit 59ae16998d
3 changed files with 11 additions and 0 deletions

View File

@ -51,6 +51,9 @@ module Vagrant
# only be used internally.
attr_accessor :temp_path
# The environment which this box belongs to
attr_accessor :env
class <<self
# Returns an array of all created boxes, as strings.
#

View File

@ -155,6 +155,7 @@ module Vagrant
return unless root_path
@box = Box.find(config.vm.box) if config.vm.box
@box.env = self if @box
end
# Loads the persisted VM (if it exists) for this environment.

View File

@ -302,6 +302,7 @@ class EnvironmentTest < Test::Unit::TestCase
context "loading box" do
setup do
@box = mock("box")
@box.stubs(:env=)
@env = mock_environment
@env.stubs(:root_path).returns("foo")
@ -327,6 +328,12 @@ class EnvironmentTest < Test::Unit::TestCase
@env.load_box!
assert @box.equal?(@env.box)
end
should "set the environment of the box" do
@box.expects(:env=).with(@env).once
Vagrant::Box.expects(:find).with(@env.config.vm.box).once.returns(@box)
@env.load_box!
end
end
context "loading the UUID out from the persisted dotfile" do