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

sartak at bestpractical.com sartak at bestpractical.com
Tue Nov 18 20:01:05 EST 2008


Author: sartak
Date: Tue Nov 18 20:01:04 2008
New Revision: 16919

Added:
   Path-Dispatcher/trunk/t/018-metadata.t
Modified:
   Path-Dispatcher/trunk/   (props changed)

Log:
 r75789 at onn:  sartak | 2008-11-18 20:01:02 -0500
 Begin writing tests for metadata


Added: Path-Dispatcher/trunk/t/018-metadata.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/018-metadata.t	Tue Nov 18 20:01:04 2008
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 2;
+use Path::Dispatcher;
+
+my @calls;
+
+my $dispatcher = Path::Dispatcher->new(
+    rules => [
+        Path::Dispatcher::Rule::Metadata->new(
+            name  => "http_method",
+            value => "GET",
+            block => sub { push @calls, $_ },
+        ),
+    ],
+);
+
+$dispatcher->run(Path::Dispatcher::Path->new(
+    path     => "the path",
+    metadata => {
+        http_method => "GET",
+    },
+));
+
+is_deeply([splice @calls], ["the path"]);
+
+$dispatcher->run(Path::Dispatcher::Path->new(
+    path     => "the path",
+    metadata => {
+        http_method => "POST",
+    },
+));
+
+is_deeply([splice @calls], [], "metadata didn't match");



More information about the Bps-public-commit mailing list