summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-10-04 10:28:54 -0500
committerJesse Luehrs <doy@tozt.net>2011-10-04 10:28:54 -0500
commit1ae483c1b1a0e602a178fa7ee8b646ac37f4e252 (patch)
treee3fd44eefc9c2af42ada06295497d4c1581fdd5b
parenta802503c8e885d5be6811d98f8f57948c69159ee (diff)
downloadox-view-tt-1ae483c1b1a0e602a178fa7ee8b646ac37f4e252.tar.gz
ox-view-tt-1ae483c1b1a0e602a178fa7ee8b646ac37f4e252.zip
a few more tests
-rw-r--r--t/data/route/templates/baz/index.tt1
-rw-r--r--t/route.t71
2 files changed, 72 insertions, 0 deletions
diff --git a/t/data/route/templates/baz/index.tt b/t/data/route/templates/baz/index.tt
new file mode 100644
index 0000000..8d5f284
--- /dev/null
+++ b/t/data/route/templates/baz/index.tt
@@ -0,0 +1 @@
+<b>Hello world: [% m.data %]</b>
diff --git a/t/route.t b/t/route.t
index 722121b..ff67ac6 100644
--- a/t/route.t
+++ b/t/route.t
@@ -113,4 +113,75 @@ test_psgi
}
};
+{
+ package Baz::Controller;
+ use Moose;
+
+ has view => (
+ is => 'ro',
+ isa => 'OX::View::TT',
+ required => 1,
+ handles => ['render'],
+ );
+
+ sub index {
+ my $self = shift;
+ my ($r) = @_;
+
+ $self->render($r, 'index.tt');
+ }
+}
+
+{
+ package Baz;
+ use OX;
+
+ has template_root => (
+ is => 'ro',
+ isa => 'Str',
+ block => sub {
+ Path::Class::dir($FindBin::Bin)->subdir('data', 'route', 'templates', 'baz')->stringify
+ },
+ );
+
+ has view => (
+ is => 'ro',
+ isa => 'OX::View::TT',
+ dependencies => ['template_root'],
+ );
+
+ has controller => (
+ is => 'ro',
+ isa => 'Baz::Controller',
+ dependencies => ['view'],
+ );
+
+ router as {
+ route '/' => 'view.template', (
+ template => 'index.tt',
+ data => 'index',
+ );
+ route '/foo' => 'controller.index', (
+ data => 'foo',
+ );
+ };
+}
+
+test_psgi
+ app => Baz->new->to_app,
+ client => sub {
+ my $cb = shift;
+
+ {
+ my $res = $cb->(GET 'http://localhost/');
+ is($res->code, 200, "right code");
+ is($res->content, "<b>Hello world: index</b>\n", "right content");
+ }
+ {
+ my $res = $cb->(GET 'http://localhost/foo');
+ is($res->code, 200, "right code");
+ is($res->content, "<b>Hello world: foo</b>\n", "right content");
+ }
+ };
+
done_testing;