Box.find sets environment of found box
This commit is contained in:
parent
36648e7a12
commit
1d518e2693
|
@ -81,7 +81,7 @@ module Vagrant
|
||||||
# @return [Box] Instance of {Box} representing the box found
|
# @return [Box] Instance of {Box} representing the box found
|
||||||
def find(env, name)
|
def find(env, name)
|
||||||
return nil unless File.directory?(directory(env, name))
|
return nil unless File.directory?(directory(env, name))
|
||||||
new(name)
|
new(env, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds a new box with given name from the given URI. This method
|
# Adds a new box with given name from the given URI. This method
|
||||||
|
@ -115,8 +115,9 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# **Note:** This method does not actually _create_ the box, but merely
|
# **Note:** This method does not actually _create_ the box, but merely
|
||||||
# returns a new, abstract representation of it. To add a box, see {#add}.
|
# returns a new, abstract representation of it. To add a box, see {#add}.
|
||||||
def initialize(name=nil)
|
def initialize(env=nil, name=nil)
|
||||||
@name = name
|
@name = name
|
||||||
|
@env = env
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns path to the OVF file of the box. The OVF file is an open
|
# Returns path to the OVF file of the box. The OVF file is an open
|
||||||
|
|
|
@ -167,7 +167,6 @@ module Vagrant
|
||||||
return unless root_path
|
return unless root_path
|
||||||
|
|
||||||
@box = Box.find(self, config.vm.box) if config.vm.box
|
@box = Box.find(self, config.vm.box) if config.vm.box
|
||||||
@box.env = self if @box
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Loads the persisted VM (if it exists) for this environment.
|
# Loads the persisted VM (if it exists) for this environment.
|
||||||
|
|
|
@ -71,6 +71,13 @@ class BoxTest < Test::Unit::TestCase
|
||||||
assert result
|
assert result
|
||||||
assert_equal @name, result.name
|
assert_equal @name, result.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return a box object with the proper env set" do
|
||||||
|
File.expects(:directory?).with(@dir).once.returns(true)
|
||||||
|
result = Vagrant::Box.find(@env, @name)
|
||||||
|
assert result
|
||||||
|
assert_equal @env, result.env
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "adding" do
|
context "adding" do
|
||||||
|
|
|
@ -345,12 +345,6 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
@env.load_box!
|
@env.load_box!
|
||||||
assert @box.equal?(@env.box)
|
assert @box.equal?(@env.box)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "set the environment of the box" do
|
|
||||||
@box.expects(:env=).with(@env).once
|
|
||||||
Vagrant::Box.expects(:find).with(@env, @env.config.vm.box).once.returns(@box)
|
|
||||||
@env.load_box!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "loading the UUID out from the persisted dotfile" do
|
context "loading the UUID out from the persisted dotfile" do
|
||||||
|
|
Loading…
Reference in New Issue