diff --git a/lib/vagrant/actions/runner.rb b/lib/vagrant/actions/runner.rb index 6d5fd0426..f7d4c3321 100644 --- a/lib/vagrant/actions/runner.rb +++ b/lib/vagrant/actions/runner.rb @@ -38,13 +38,14 @@ module Vagrant # Call the prepare method on each once its # initialized, then call the execute! method - return_value = nil [:prepare, :execute!].each do |method| actions.each do |action| - return_value = action.send(method) + action.send(method) end end - return_value + + # Clear the actions + actions.clear end # Invokes an "around callback" which invokes before_name and diff --git a/test/vagrant/actions/runner_test.rb b/test/vagrant/actions/runner_test.rb index 64d736461..7f4952718 100644 --- a/test/vagrant/actions/runner_test.rb +++ b/test/vagrant/actions/runner_test.rb @@ -1,6 +1,13 @@ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') class ActionRunnerTest < Test::Unit::TestCase + def mock_fake_action + action = mock("action") + action.stubs(:prepare) + action.stubs(:execute!) + action + end + context "callbacks" do setup do @runner = Vagrant::Actions::Runner.new @@ -104,6 +111,14 @@ class ActionRunnerTest < Test::Unit::TestCase @runner.execute!(run_class) end + should "clear actions after running execute!" do + @runner.actions << mock_fake_action + @runner.actions << mock_fake_action + assert !@runner.actions.empty? # sanity + @runner.execute! + assert @runner.actions.empty? + end + should "run #prepare on all actions, then #execute!" do action_seq = sequence("action_seq") actions = []