diff --git a/lib/vagrant/action/builtin.rb b/lib/vagrant/action/builtin.rb index f04c1b170..5162531c6 100644 --- a/lib/vagrant/action/builtin.rb +++ b/lib/vagrant/action/builtin.rb @@ -117,6 +117,12 @@ module Vagrant end 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 diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 35630bff1..a6468ccd6 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -210,6 +210,7 @@ module Vagrant self.class.check_virtualbox! load_config! load_vm! + actions.run(:environment_load) self end diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index fff14b793..9e10c4a4c 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -165,30 +165,24 @@ class EnvironmentTest < Test::Unit::TestCase end context "accessing host" do - setup do - @env = vagrant_env - end - should "load the host once" do + env = @klass.new(:cwd => vagrant_app) result = mock("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 + 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 end end context "accessing actions" do - setup do - @env = vagrant_env - end - should "initialize the Action object with the given environment" do + env = @klass.new(:cwd => vagrant_app) result = mock("result") - Vagrant::Action.expects(:new).with(@env).returns(result).once - assert_equal result, @env.actions - assert_equal result, @env.actions - assert_equal result, @env.actions + Vagrant::Action.expects(:new).with(env).returns(result).once + assert_equal result, env.actions + assert_equal result, env.actions + assert_equal result, env.actions end end @@ -328,6 +322,7 @@ class EnvironmentTest < Test::Unit::TestCase @klass.expects(:check_virtualbox!).once.in_sequence(call_seq) @env.expects(:load_config!).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! end end