Action runner clears actions after execution

This commit is contained in:
Mitchell Hashimoto 2010-02-24 00:39:12 -08:00
parent e4548508f2
commit f1fc07e353
2 changed files with 19 additions and 3 deletions

View File

@ -38,13 +38,14 @@ module Vagrant
# Call the prepare method on each once its # Call the prepare method on each once its
# initialized, then call the execute! method # initialized, then call the execute! method
return_value = nil
[:prepare, :execute!].each do |method| [:prepare, :execute!].each do |method|
actions.each do |action| actions.each do |action|
return_value = action.send(method) action.send(method)
end end
end end
return_value
# Clear the actions
actions.clear
end end
# Invokes an "around callback" which invokes before_name and # Invokes an "around callback" which invokes before_name and

View File

@ -1,6 +1,13 @@
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
class ActionRunnerTest < Test::Unit::TestCase class ActionRunnerTest < Test::Unit::TestCase
def mock_fake_action
action = mock("action")
action.stubs(:prepare)
action.stubs(:execute!)
action
end
context "callbacks" do context "callbacks" do
setup do setup do
@runner = Vagrant::Actions::Runner.new @runner = Vagrant::Actions::Runner.new
@ -104,6 +111,14 @@ class ActionRunnerTest < Test::Unit::TestCase
@runner.execute!(run_class) @runner.execute!(run_class)
end 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 should "run #prepare on all actions, then #execute!" do
action_seq = sequence("action_seq") action_seq = sequence("action_seq")
actions = [] actions = []