begin rescue added
This commit is contained in:
parent
114511742e
commit
b251d9b954
|
@ -10,7 +10,18 @@ module Vagrant
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
return if @actions.empty?
|
return if @actions.empty?
|
||||||
@stack.push(@actions.pop).last.call(env)
|
|
||||||
|
if env.error?
|
||||||
|
begin_rescue(env)
|
||||||
|
else
|
||||||
|
@stack.push(@actions.pop).last.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def begin_rescue(env)
|
||||||
|
@stack.reverse.each do |action|
|
||||||
|
action.rescue(env) if actions.respond_to?(:rescue)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize_action(action, env)
|
def finalize_action(action, env)
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ActionWardenTest < Test::Unit::TestCase
|
||||||
middleware.each do |m|
|
middleware.each do |m|
|
||||||
@klass.any_instance.expects(:finalize_action).with(m, {}).returns(m)
|
@klass.any_instance.expects(:finalize_action).with(m, {}).returns(m)
|
||||||
end
|
end
|
||||||
@warden = @klass.new(middleware, {})
|
@warden = @klass.new(middleware, new_env)
|
||||||
assert_equal @warden.actions, [3,2,1]
|
assert_equal @warden.actions, [3,2,1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,13 +36,13 @@ class ActionWardenTest < Test::Unit::TestCase
|
||||||
context "calling" do
|
context "calling" do
|
||||||
should "return if there are no actions to execute" do
|
should "return if there are no actions to execute" do
|
||||||
@instance.actions.expects(:pop).never
|
@instance.actions.expects(:pop).never
|
||||||
assert !@instance.call({})
|
assert !@instance.call(new_env)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "move the last action to the front of the stack" do
|
should "move the last action to the front of the stack" do
|
||||||
@instance.actions << lambda {}
|
@instance.actions << lambda {}
|
||||||
assert @instance.stack.empty?
|
assert @instance.stack.empty?
|
||||||
@instance.call({})
|
@instance.call(new_env)
|
||||||
assert !@instance.stack.empty?
|
assert !@instance.stack.empty?
|
||||||
assert @instance.actions.empty?
|
assert @instance.actions.empty?
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,11 @@ class ActionWardenTest < Test::Unit::TestCase
|
||||||
action = mock('action')
|
action = mock('action')
|
||||||
action.expects(:call).with({})
|
action.expects(:call).with({})
|
||||||
@instance.actions << action
|
@instance.actions << action
|
||||||
@instance.call({})
|
@instance.call(new_env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_env
|
||||||
|
Vagrant::Action::Environment.new(nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue