[Bps-public-commit] r16783 - in Path-Dispatcher/trunk: t

sartak at bestpractical.com sartak at bestpractical.com
Sun Nov 9 12:44:46 EST 2008


Author: sartak
Date: Sun Nov  9 12:44:46 2008
New Revision: 16783

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/t/101-subclass.t

Log:
 r75353 at onn:  sartak | 2008-11-09 12:40:44 -0500
 Begin improving the declarative tests


Modified: Path-Dispatcher/trunk/t/101-subclass.t
==============================================================================
--- Path-Dispatcher/trunk/t/101-subclass.t	(original)
+++ Path-Dispatcher/trunk/t/101-subclass.t	Sun Nov  9 12:44:46 2008
@@ -1,45 +1,42 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 5;
-use lib 't/lib';
-use Path::Dispatcher::Test::App;
+use Test::More tests => 2;
 
-our @calls;
+my @calls;
 
-Path::Dispatcher::Test::Framework->run('foo');
-is_deeply([splice @calls], [
-    'framework before foo',
-#    'framework on foo',
-#    'framework after foo',
-]);
+do {
+    package MyFramework::Dispatcher;
+    use Path::Dispatcher::Declarative -base;
 
-Path::Dispatcher::Test::App->run('foo');
-is_deeply([splice @calls], [
-    'app before foo',
-#    'app after foo',
-#    'framework before foo',
-#    'framework on foo',
-#    'framework after foo',
-]);
+    on 'quit' => sub { push @calls, 'framework: quit' };
+
+    package MyApp::Dispatcher;
+    # this hack is here because "use" expects there to be a file for the module
+    BEGIN { MyFramework::Dispatcher->import("-base") }
 
-Path::Dispatcher::Test::App->dispatcher->add_rule(
-    Path::Dispatcher::Rule::Regex->new(
-        regex => qr/foo/,
-        block => sub {
-            push @calls, 'app on foo';
-        },
-    ),
-);
+    on qr/.*/ => sub {
+        push @calls, 'app: first .*';
+        next_rule;
+    };
 
-Path::Dispatcher::Test::App->run('foo');
+    redispatch_to('MyFramework::Dispatcher');
+
+    on qr/.*/ => sub {
+        push @calls, 'app: second .*';
+        next_rule;
+    };
+};
+
+MyApp::Dispatcher->run("quit");
 is_deeply([splice @calls], [
-    'app before foo',
-#    'app on foo',
-#    'app after foo',
+    'app: first .*',
+    'framework: quit',
 ]);
 
-for ('Path::Dispatcher::Test::Framework', 'Path::Dispatcher::Test::App') {
-    is($_->dispatcher->name, $_, "correct dispatcher name for $_");
-}
+MyApp::Dispatcher->run("other");
+is_deeply([splice @calls], [
+    'app: first .*',
+    'app: second .*',
+]);
 



More information about the Bps-public-commit mailing list