[Bps-public-commit] Path-Dispatcher branch, named_captures, updated. a467f7ef576f8a8eca263d90e51a012e80ede977

Shawn Moore sartak at bestpractical.com
Thu Jun 24 15:58:33 EDT 2010


The branch, named_captures has been updated
       via  a467f7ef576f8a8eca263d90e51a012e80ede977 (commit)
      from  7a92e2e60270451568ea17392ea91d5cd8563c29 (commit)

Summary of changes:
 t/905-under-named.t |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 t/905-under-named.t

- Log -----------------------------------------------------------------
commit a467f7ef576f8a8eca263d90e51a012e80ede977
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Jun 24 15:58:49 2010 -0400

    Make sure capture vars work with "under"

diff --git a/t/905-under-named.t b/t/905-under-named.t
new file mode 100644
index 0000000..aed7258
--- /dev/null
+++ b/t/905-under-named.t
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 2;
+use Test::Exception;
+use Path::Dispatcher;
+
+my @pos;
+my @named;
+
+my $dispatcher = Path::Dispatcher->new(
+    rules => [
+        Path::Dispatcher::Rule::Under->new(
+            predicate => Path::Dispatcher::Rule::Regex->new(
+                regex  => qr/(?<type>\w+)/,
+                prefix => 1,
+            ),
+            rules => [
+                Path::Dispatcher::Rule::Tokens->new(
+                    tokens => [qr/(?<operation>\w+)/, qr/(?<id>\d+)/],
+                    block  => sub {
+                        push @pos, [$1, $2, $3, $4];
+                        push @named, \%+;
+                    },
+                ),
+            ],
+        ),
+    ],
+);
+
+$dispatcher->run("ticket update 10");
+is_deeply([splice @pos], [['ticket', 'update', 10, undef]]);
+is_deeply([splice @named], [{
+    type      => 'ticket',
+    operation => 'update',
+    id        => 10,
+}]);
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list