@@ -188,7 +188,7 @@ def test_middleware_invocation_on_404
188188 end
189189end
190190
191- class MiddlewareTest < Minitest ::Test
191+ class MiddlewareHooksTest < Minitest ::Test
192192 HTTP = Syntropy ::HTTP
193193
194194 APP_ROOT = File . join ( __dir__ , 'fixtures/app_hooks' )
@@ -228,6 +228,46 @@ def test_middleware_composition
228228 end
229229end
230230
231+ class ErrorHandlerTest < Minitest ::Test
232+ HTTP = Syntropy ::HTTP
233+
234+ APP_ROOT = File . join ( __dir__ , 'fixtures/app_errors' )
235+
236+ def setup
237+ @machine = UM . new
238+
239+ @tmp_path = '/test/tmp'
240+ @tmp_fn = File . join ( APP_ROOT , 'tmp.rb' )
241+
242+ @app = Syntropy ::App . new (
243+ app_root : APP_ROOT ,
244+ mount_path : '/' ,
245+ watch_files : 0.05 ,
246+ machine : @machine
247+ )
248+
249+ @test_harness = Syntropy ::TestHarness . new ( @app )
250+ end
251+
252+ def test_error_handlers
253+ req = @test_harness . request ( ':method' => 'GET' , ':path' => '/' )
254+ assert_equal HTTP ::TEAPOT , req . response_status
255+ assert_equal 'root: root' , req . response_body
256+
257+ req = @test_harness . request ( ':method' => 'GET' , ':path' => '/foo' )
258+ assert_equal HTTP ::TEAPOT , req . response_status
259+ assert_equal 'foo: foo' , req . response_body
260+
261+ req = @test_harness . request ( ':method' => 'GET' , ':path' => '/foo/bar' )
262+ assert_equal HTTP ::TEAPOT , req . response_status
263+ assert_equal 'bar: bar' , req . response_body
264+
265+ req = @test_harness . request ( ':method' => 'GET' , ':path' => '/foo/bar/baz' )
266+ assert_equal HTTP ::TEAPOT , req . response_status
267+ assert_equal 'bar: baz' , req . response_body
268+ end
269+ end
270+
231271class CustomAppTest < Minitest ::Test
232272 HTTP = Syntropy ::HTTP
233273
0 commit comments