[Catalyst-commits] r6778 - in trunk/Catalyst-View-Mason/t: . lib
lib/TestApp/View/Mason lib/TestApp/root
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Tue Aug 28 17:00:36 GMT 2007
Author: rafl
Date: 2007-08-28 17:00:35 +0100 (Tue, 28 Aug 2007)
New Revision: 6778
Added:
trunk/Catalyst-View-Mason/t/globals.t
trunk/Catalyst-View-Mason/t/lib/TestApp/root/additional_globals
trunk/Catalyst-View-Mason/t/lib/TestApp/root/globals
Modified:
trunk/Catalyst-View-Mason/t/lib/TestApp.pm
trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/Pkgconfig.pm
Log:
Test default globals as well as additional globals.
Added: trunk/Catalyst-View-Mason/t/globals.t
===================================================================
--- trunk/Catalyst-View-Mason/t/globals.t (rev 0)
+++ trunk/Catalyst-View-Mason/t/globals.t 2007-08-28 16:00:35 UTC (rev 6778)
@@ -0,0 +1,23 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 8;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use_ok('Catalyst::Test', 'TestApp');
+
+my $response = request('/globals');
+ok($response->is_success, 'request ok');
+
+like($response->content, qr{\b c \s+ => \s+ TestApp \b}x, 'global c');
+like($response->content, qr{\b base \s+ => \s+ http:// \b}x, 'global base');
+like($response->content, qr{\b name \s+ => \s+ TestApp \b}x, 'global name');
+
+$response = request('/additional_globals');
+ok($response->is_success, 'request ok');
+
+like($response->content, qr{\b foo \s+ => \s+ 123 \b}x, 'global foo');
+like($response->content, qr{\b bar \s+ => \s+ \[moo, \s+ kooh\] }x, 'global bar');
Modified: trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/Pkgconfig.pm
===================================================================
--- trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/Pkgconfig.pm 2007-08-28 16:00:12 UTC (rev 6777)
+++ trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/Pkgconfig.pm 2007-08-28 16:00:35 UTC (rev 6778)
@@ -4,4 +4,8 @@
use warnings;
use base 'Catalyst::View::Mason';
+__PACKAGE__->config(
+ allow_globals => [qw/$foo @bar/],
+);
+
1;
Added: trunk/Catalyst-View-Mason/t/lib/TestApp/root/additional_globals
===================================================================
--- trunk/Catalyst-View-Mason/t/lib/TestApp/root/additional_globals (rev 0)
+++ trunk/Catalyst-View-Mason/t/lib/TestApp/root/additional_globals 2007-08-28 16:00:35 UTC (rev 6778)
@@ -0,0 +1,9 @@
+<%init>
+$foo = 123;
+ at bar = qw/moo kooh/;
+</%init>
+
+{
+ foo => <% $foo %>,
+ bar => [<% join (q/, /, @bar) %>],
+}
Added: trunk/Catalyst-View-Mason/t/lib/TestApp/root/globals
===================================================================
--- trunk/Catalyst-View-Mason/t/lib/TestApp/root/globals (rev 0)
+++ trunk/Catalyst-View-Mason/t/lib/TestApp/root/globals 2007-08-28 16:00:35 UTC (rev 6778)
@@ -0,0 +1,5 @@
+{
+ c => <% $c %>,
+ name => <% $name %>,
+ base => <% $base %>,
+}
Modified: trunk/Catalyst-View-Mason/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-View-Mason/t/lib/TestApp.pm 2007-08-28 16:00:12 UTC (rev 6777)
+++ trunk/Catalyst-View-Mason/t/lib/TestApp.pm 2007-08-28 16:00:35 UTC (rev 6778)
@@ -69,6 +69,12 @@
$c->stash->{message} = $c->request->captures->[0];
}
+sub globals : Local {
+}
+
+sub additional_globals : Local {
+}
+
sub end : Private {
my ($self, $c) = @_;
More information about the Catalyst-commits
mailing list