Run "environment_load" action on environment load
This commit is contained in:
parent
1a5836ee23
commit
1478818939
|
@ -117,6 +117,12 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
register :box_repackage, box_repackage
|
register :box_repackage, box_repackage
|
||||||
|
|
||||||
|
# post_load - Called after environment is loaded
|
||||||
|
environment_load = Builder.new do
|
||||||
|
end
|
||||||
|
|
||||||
|
register :environment_load, environment_load
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -210,6 +210,7 @@ module Vagrant
|
||||||
self.class.check_virtualbox!
|
self.class.check_virtualbox!
|
||||||
load_config!
|
load_config!
|
||||||
load_vm!
|
load_vm!
|
||||||
|
actions.run(:environment_load)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -165,30 +165,24 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
context "accessing host" do
|
context "accessing host" do
|
||||||
setup do
|
|
||||||
@env = vagrant_env
|
|
||||||
end
|
|
||||||
|
|
||||||
should "load the host once" do
|
should "load the host once" do
|
||||||
|
env = @klass.new(:cwd => vagrant_app)
|
||||||
result = mock("result")
|
result = mock("result")
|
||||||
Vagrant::Hosts::Base.expects(:load).with(@env, @env.config.vagrant.host).once.returns(result)
|
Vagrant::Hosts::Base.expects(:load).with(env, env.config.vagrant.host).once.returns(result)
|
||||||
assert_equal result, @env.host
|
assert_equal result, env.host
|
||||||
assert_equal result, @env.host
|
assert_equal result, env.host
|
||||||
assert_equal result, @env.host
|
assert_equal result, env.host
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "accessing actions" do
|
context "accessing actions" do
|
||||||
setup do
|
|
||||||
@env = vagrant_env
|
|
||||||
end
|
|
||||||
|
|
||||||
should "initialize the Action object with the given environment" do
|
should "initialize the Action object with the given environment" do
|
||||||
|
env = @klass.new(:cwd => vagrant_app)
|
||||||
result = mock("result")
|
result = mock("result")
|
||||||
Vagrant::Action.expects(:new).with(@env).returns(result).once
|
Vagrant::Action.expects(:new).with(env).returns(result).once
|
||||||
assert_equal result, @env.actions
|
assert_equal result, env.actions
|
||||||
assert_equal result, @env.actions
|
assert_equal result, env.actions
|
||||||
assert_equal result, @env.actions
|
assert_equal result, env.actions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -328,6 +322,7 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
@klass.expects(:check_virtualbox!).once.in_sequence(call_seq)
|
@klass.expects(:check_virtualbox!).once.in_sequence(call_seq)
|
||||||
@env.expects(:load_config!).once.in_sequence(call_seq)
|
@env.expects(:load_config!).once.in_sequence(call_seq)
|
||||||
@env.expects(:load_vm!).once.in_sequence(call_seq)
|
@env.expects(:load_vm!).once.in_sequence(call_seq)
|
||||||
|
@env.actions.expects(:run).with(:environment_load).once.in_sequence(call_seq)
|
||||||
assert_equal @env, @env.load!
|
assert_equal @env, @env.load!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue