From: Tomas Doran Date: Sun, 24 Jan 2010 22:17:10 +0000 (+0000) Subject: Test the app. This is grotty, as it just expects the entire page. But it's better... X-Git-Tag: 0.07_01~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-View-Component-SubInclude.git;a=commitdiff_plain;h=c33bb2368e4b3ad3c1e0555d3f188f3e0f682372 Test the app. This is grotty, as it just expects the entire page. But it's better than no tests at all --- diff --git a/Makefile.PL b/Makefile.PL index b45f639..3e8a8dd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -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 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
+Current time is: [\w\s:]+ --> | foo = bar | +
+Current time is: [\w\s:]+ --> Capture Arg: test| baz = quux | +
+ +

+Test subinclude using specific plugins:
+Current time is: [\w\s:]+ --> | plugin = SubRequest | +
+Current time is: [\w\s:]+ --> | plugin = Visit | +
+
+ +

+ + +Test CaptureArgs and Args interaction (SubRequest):

+ +Current time is: [\w\s:]+ --> Capture Arg: capture_argtest | query_arg = val | Action Arg: regular_arg +
+(using: http://localhost/capture_argtest/time/regular_arg?query_arg=val)
+
+ +Current time is: [\w\s:]+ --> | query_arg = val | Action Arg: regular_arg +
+(using: http://localhost/time/regular_arg?query_arg=val)
+ +

+ +Test CaptureArgs and Args interaction (Visit):

+ +Current time is: [\w\s:]+ --> Capture Arg: capture_argtest | query_arg = val | Action Arg: regular_arg +
+(using: http://localhost/capture_argtest/time/regular_arg?query_arg=val)
+
+ +Current time is: [\w\s:]+ --> | query_arg = val | Action Arg: regular_arg +
+(using: http://localhost/time/regular_arg?query_arg=val)
+ +

+ +Test CaptureArgs and Args interaction (ESI):

+ +
+(using: http://localhost/capture_argtest/time/regular_arg?query_arg=val)
+
+ +
+(using: http://localhost/time/regular_arg?query_arg=val)
+ +


+ +Test Args when Chained is not being used: +Current time is: [\w\s:]+ --> | query_arg = val | No Chained Args: regular_arg1, regular_arg2 +
+(using: http://localhost/time_args_no_chained/regular_arg1/regular_arg2?query_arg=val)
+}; + +done_testing; diff --git a/t/lib/ESITest/Controller/Root.pm b/t/lib/ESITest/Controller/Root.pm index db509be..6a9dc31 100644 --- a/t/lib/ESITest/Controller/Root.pm +++ b/t/lib/ESITest/Controller/Root.pm @@ -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"; }