test/unit/error_handler_tests.rb in deas-0.13.1 vs test/unit/error_handler_tests.rb in deas-0.14.0

- old
+ new

@@ -5,12 +5,12 @@ class BaseTests < Assert::Context desc "Deas::ErrorHandler" setup do @exception = RuntimeError.new - @fake_app = FakeApp.new - @error_handler = Deas::ErrorHandler.new(@exception, @fake_app, []) + @fake_sinatra_call = FakeSinatraCall.new + @error_handler = Deas::ErrorHandler.new(@exception, @fake_sinatra_call, []) end subject{ @error_handler } should have_instance_methods :run should have_class_methods :run @@ -23,16 +23,16 @@ @error_procs = [ proc do |exception| settings.exception_that_occurred = exception "my return value" end ] - @error_handler = Deas::ErrorHandler.new(@exception, @fake_app, @error_procs) + @error_handler = Deas::ErrorHandler.new(@exception, @fake_sinatra_call, @error_procs) @response = @error_handler.run end should "run the proc in the context of the app" do - assert_equal @exception, @fake_app.settings.exception_that_occurred + assert_equal @exception, @fake_sinatra_call.settings.exception_that_occurred end should "return whatever the proc returns" do assert_equal "my return value", @response end @@ -55,18 +55,18 @@ settings.third_proc_run = true nil end ] - @error_handler = Deas::ErrorHandler.new(@exception, @fake_app, @error_procs) + @error_handler = Deas::ErrorHandler.new(@exception, @fake_sinatra_call, @error_procs) @response = @error_handler.run end should "run all the error procs" do - assert_equal true, @fake_app.settings.first_proc_run - assert_equal true, @fake_app.settings.second_proc_run - assert_equal true, @fake_app.settings.third_proc_run + assert_equal true, @fake_sinatra_call.settings.first_proc_run + assert_equal true, @fake_sinatra_call.settings.second_proc_run + assert_equal true, @fake_sinatra_call.settings.third_proc_run end should "return the last non-nil response" do assert_equal 'second', @response end @@ -84,16 +84,16 @@ proc do |exception| settings.second_proc_run = true end ] - @error_handler = Deas::ErrorHandler.new(@exception, @fake_app, @error_procs) + @error_handler = Deas::ErrorHandler.new(@exception, @fake_sinatra_call, @error_procs) @response = catch(:halt){ @error_handler.run } end should "run error procs until one halts" do - assert_equal true, @fake_app.settings.first_proc_run - assert_nil @fake_app.settings.second_proc_run + assert_equal true, @fake_sinatra_call.settings.first_proc_run + assert_nil @fake_sinatra_call.settings.second_proc_run end should "return whatever was halted" do assert_equal [ 401 ], @response end