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
# 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

View File

@ -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 = []