test/vagrant/action/warden_test.rb in vagrantup-0.7.8 vs test/vagrant/action/warden_test.rb in vagrantup-0.8.0

- old
+ new

@@ -1,20 +1,22 @@ require "test_helper" +require "logger" class ActionWardenTest < Test::Unit::TestCase setup do @klass = Vagrant::Action::Warden @instance = @klass.new([], {}) end context "initializing" do should "finalize the middleware" do + env = new_env middleware = [1,2,3] middleware.each do |m| - @klass.any_instance.expects(:finalize_action).with(m, {}).returns(m) + @klass.any_instance.expects(:finalize_action).with(m, env).returns(m) end - @warden = @klass.new(middleware, new_env) + @warden = @klass.new(middleware, env) assert_equal @warden.actions, [1,2,3] end end context "setting up middleware" do @@ -46,14 +48,15 @@ assert !@instance.stack.empty? assert @instance.actions.empty? end should "call the next action" do + env = new_env action = mock('action') - action.expects(:call).with({}) + action.expects(:call).with(env) @instance.actions << action - @instance.call(new_env) + @instance.call(env) end should "begin recovery sequence when the called action raises an exception" do class Foo def initialize(*args); end @@ -95,21 +98,24 @@ end end context "recover" do should "call recover on all items in the stack" do + env = new_env seq = sequence("sequence") @instance.stack = [rescueable_mock("action"), rescueable_mock("another")] @instance.stack.each do |action| - action.expects(:recover).with(new_env).in_sequence(seq) + action.expects(:recover).with(env).in_sequence(seq) end - @instance.begin_rescue(new_env) + @instance.begin_rescue(env) end end def new_env - Vagrant::Action::Environment.new(nil) + env = Vagrant::Action::Environment.new(nil) + env["logger"] = Logger.new(nil) + env end def rescueable_mock(name) mock_action = mock(name) mock_action.stubs(:respond_to?).with(:recover).returns(true)