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

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 29 15:18:08 EDT 2008


Author: sartak
Date: Tue Jul 29 15:17:54 2008
New Revision: 14612

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
   Path-Dispatcher/trunk/t/001-api.t

Log:
 r67895 at onn:  sartak | 2008-07-29 15:17:48 -0400
 Better test Jifty::Dispatcher compat - each rule coderef receives no arguments


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	Tue Jul 29 15:17:54 2008
@@ -43,7 +43,7 @@
     my $self = shift;
     my $path = shift;
 
-    $self->block->($path);
+    $self->block->();
 }
 
 __PACKAGE__->meta->make_immutable;

Modified: Path-Dispatcher/trunk/t/001-api.t
==============================================================================
--- Path-Dispatcher/trunk/t/001-api.t	(original)
+++ Path-Dispatcher/trunk/t/001-api.t	Tue Jul 29 15:17:54 2008
@@ -4,24 +4,22 @@
 use Test::More tests => 4;
 use Path::Dispatcher;
 
-my $calls = 0;
+my @calls;
 
 my $dispatcher = Path::Dispatcher->new;
 $dispatcher->add_rule(
-    stage => 'on',
     match => 'foo',
-    block => sub { ++$calls },
+    block => sub { push @calls, [@_] },
 );
 
-is($calls, 0, "no calls to the dispatcher block yet");
+is_deeply([splice @calls], [], "no calls to the rule block yet");
+
 my $thunk = $dispatcher->dispatch('foo');
-is($calls, 0, "no calls to the dispatcher block yet");
+is_deeply([splice @calls], [], "no calls to the rule block yet");
 
 $thunk->();
-is($calls, 1, "made a call to the dispatcher block");
-
-$calls = 0;
+is_deeply([splice @calls], [ [] ], "finally invoked the rule block");
 
 $dispatcher->run('foo');
-is($calls, 1, "run does all three stages");
+is_deeply([splice @calls], [ [] ], "invoked the rule block on 'run'");
 



More information about the Bps-public-commit mailing list