[Bps-public-commit] Path-Dispatcher branch, master, updated. a37ba128c5a271a440ccfd2880fb34ff90a561cb
Shawn Moore
sartak at bestpractical.com
Tue Apr 19 17:53:36 EDT 2011
The branch, master has been updated
via a37ba128c5a271a440ccfd2880fb34ff90a561cb (commit)
from dcd650099fc6afc71200c3a7c135a7d1c68d1bca (commit)
Summary of changes:
t/033-chain.t | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
create mode 100644 t/033-chain.t
- Log -----------------------------------------------------------------
commit a37ba128c5a271a440ccfd2880fb34ff90a561cb
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Apr 19 17:53:29 2011 -0400
Tests for the Chain rule type
diff --git a/t/033-chain.t b/t/033-chain.t
new file mode 100644
index 0000000..e8db5fd
--- /dev/null
+++ b/t/033-chain.t
@@ -0,0 +1,51 @@
+use strict;
+use warnings;
+use Test::More;
+use Path::Dispatcher;
+
+my @calls;
+
+my $dispatcher = Path::Dispatcher->new(
+ rules => [
+ Path::Dispatcher::Rule::Under->new(
+ predicate => Path::Dispatcher::Rule::Tokens->new(
+ tokens => ['show'],
+ prefix => 1,
+ ),
+ rules => [
+ Path::Dispatcher::Rule::Chain->new(
+ block => sub { push @calls, 'chain' },
+ ),
+ Path::Dispatcher::Rule::Tokens->new(
+ tokens => ['inventory'],
+ block => sub { push @calls, 'inventory' },
+ ),
+ Path::Dispatcher::Rule::Tokens->new(
+ tokens => ['score'],
+ block => sub { push @calls, 'score' },
+ ),
+ ],
+ ),
+ ],
+);
+
+$dispatcher->run("show inventory");
+is_deeply([splice @calls], [ 'chain', 'inventory' ]);
+
+$dispatcher->run("show score");
+is_deeply([splice @calls], [ 'chain', 'score' ]);
+
+$dispatcher->run("show nothing");
+is_deeply([splice @calls], [ ]);
+
+$dispatcher->run("do nothing");
+is_deeply([splice @calls], [ ]);
+
+$dispatcher->run("do inventory");
+is_deeply([splice @calls], [ ]);
+
+$dispatcher->run("do score");
+is_deeply([splice @calls], [ ]);
+
+done_testing;
+
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list