diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index a6468ccd6..91f28830e 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -206,11 +206,14 @@ module Vagrant # such as `vm`, `config`, etc. on this environment. The order this # method calls its other methods is very particular. def load! - @loaded = true - self.class.check_virtualbox! - load_config! - load_vm! - actions.run(:environment_load) + if !loaded? + @loaded = true + self.class.check_virtualbox! + load_config! + load_vm! + actions.run(:environment_load) + end + self end diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index 9e10c4a4c..14c251cf0 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -318,12 +318,13 @@ class EnvironmentTest < Test::Unit::TestCase context "overall load method" do should "load! should call proper sequence and return itself" do + env = @klass.new(:cwd => vagrantfile) call_seq = sequence("call_sequence") @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! + 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