Add uri_with tests (nothing was broken, but I had some problems locally and
Cory G Watson [Tue, 14 Apr 2009 14:25:22 +0000 (14:25 +0000)]
test coverage is always good)

Changes
t/unit_core_uri_with.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index e82bf60..481b0cb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -63,6 +63,7 @@
           cases (t0m)
           - Tests for this (t0m)
         - Use of deprecated Catalyst::Base now warns. (t0m)
+        - Add uri_with tests (gphat)
 
 5.8000_06 2009-02-04 21:00
         - Disallow writing to config after setup (rafl)
diff --git a/t/unit_core_uri_with.t b/t/unit_core_uri_with.t
new file mode 100644 (file)
index 0000000..a35f758
--- /dev/null
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+use URI;
+
+use_ok('Catalyst::Request');
+
+my $request = Catalyst::Request->new( {
+                uri => URI->new('http://127.0.0.1/foo/bar/baz')
+              } );
+
+is(
+    $request->uri_with({}),
+    'http://127.0.0.1/foo/bar/baz',
+    'URI for absolute path'
+);
+
+is(
+    $request->uri_with({ foo => 'bar' }),
+    'http://127.0.0.1/foo/bar/baz?foo=bar',
+    'URI adds param'
+);
+
+my $request2 = Catalyst::Request->new( {
+                uri => URI->new('http://127.0.0.1/foo/bar/baz?bar=gorch')
+              } );
+is(
+    $request2->uri_with({}),
+    'http://127.0.0.1/foo/bar/baz?bar=gorch',
+    'URI retains param'
+);
+
+is(
+    $request2->uri_with({ me => 'awesome' }),
+    'http://127.0.0.1/foo/bar/baz?bar=gorch&me=awesome',
+    'URI retains param and adds new'
+);
+
+is(
+    $request2->uri_with({ bar => undef }),
+    'http://127.0.0.1/foo/bar/baz',
+    'URI loses param when explicitly undef'
+);
+
+is(
+    $request2->uri_with({ bar => 'snort' }),
+    'http://127.0.0.1/foo/bar/baz?bar=snort',
+    'URI changes param'
+);