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