Test the app. This is grotty, as it just expects the entire page. But it's better...
Tomas Doran [Sun, 24 Jan 2010 22:17:10 +0000 (22:17 +0000)]
Makefile.PL
t/app.t [new file with mode: 0644]
t/lib/ESITest/Controller/Root.pm

index b45f639..3e8a8dd 100644 (file)
@@ -14,6 +14,7 @@ requires 'Moose::Role';
 requires 'Carp';
 requires 'namespace::clean';
 
+test_requires 'Test::More' => '0.88';
 test_requires 'Catalyst::View::TT';
 
 author_requires 'Test::Pod::Coverage' => '1.04';
diff --git a/t/app.t b/t/app.t
new file mode 100644 (file)
index 0000000..5dd1cf7
--- /dev/null
+++ b/t/app.t
@@ -0,0 +1,70 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+
+use Test::More;
+use Catalyst::Test 'ESITest';
+
+like get('/'),
+qr{SubInclude test: will include /time_include using default plugin Catalyst::View::Component::SubInclude::Visit<br/>
+Current time is: [\w\s:]+ --> | foo = bar | 
+<br/>
+Current time is: [\w\s:]+ --> Capture Arg: test| baz = quux | 
+<br/>
+
+<br/><br/>
+Test subinclude using specific plugins:<br/>
+Current time is: [\w\s:]+ --> | plugin = SubRequest | 
+<br/>
+Current time is: [\w\s:]+ --> | plugin = Visit | 
+<br/>
+<!--esi <esi:include src="/time?plugin=ESI" /> --><br/>
+
+<br/><br/>
+
+
+Test CaptureArgs and Args interaction (SubRequest):<br/><br/>
+
+Current time is: [\w\s:]+ --> Capture Arg: capture_argtest | query_arg = val |  Action Arg: regular_arg 
+<br/>
+(using: http://localhost/capture_argtest/time/regular_arg?query_arg=val)<br/>
+<br/>
+
+Current time is: [\w\s:]+ -->  | query_arg = val |  Action Arg: regular_arg 
+<br/>
+(using: http://localhost/time/regular_arg?query_arg=val)<br/>
+
+<br/><br/>
+
+Test CaptureArgs and Args interaction (Visit):<br/><br/>
+
+Current time is: [\w\s:]+ --> Capture Arg: capture_argtest | query_arg = val |  Action Arg: regular_arg 
+<br/>
+(using: http://localhost/capture_argtest/time/regular_arg?query_arg=val)<br/>
+<br/>
+
+Current time is: [\w\s:]+ -->  | query_arg = val |  Action Arg: regular_arg 
+<br/>
+(using: http://localhost/time/regular_arg?query_arg=val)<br/>
+
+<br/><br/>
+
+Test CaptureArgs and Args interaction (ESI):<br/><br/>
+
+<!--esi <esi:include src="/capture_argtest/time/regular_arg?query_arg=val" /> --><br/>
+(using: http://localhost/capture_argtest/time/regular_arg?query_arg=val)<br/>
+<br/>
+
+<!--esi <esi:include src="/time/regular_arg?query_arg=val" /> --><br/>
+(using: http://localhost/time/regular_arg?query_arg=val)<br/>
+
+<br/><br/><br/>
+
+Test Args when Chained is not being used:
+Current time is: [\w\s:]+ -->  | query_arg = val |  No Chained Args: regular_arg1, regular_arg2
+<br/>
+(using: http://localhost/time_args_no_chained/regular_arg1/regular_arg2?query_arg=val)<br/>
+};
+
+done_testing;
index db509be..6a9dc31 100644 (file)
@@ -31,7 +31,7 @@ sub time_include : Chained('base') PathPart('time') Args(0) {
 
 sub capture : Chained('base') PathPart('') CaptureArgs(1) {
     my ( $self, $c, $arg ) = @_;
-    $c->log->debug("Capture: $arg");
+    $c->log->debug("Capture: $arg") if $c->debug;
     $c->stash->{additional} = "Capture Arg: $arg";
 }