summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-07 00:48:57 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-07 00:48:57 -0500
commit4bba62eb8de961cbfc0ba53cd26b9667db551748 (patch)
treed609dafdbda1019e65b2bf4c88fbcb666e624481
parentbee0ff8a0fc620f0359d60b23b1e15991163ea04 (diff)
downloadplack-middleware-xslate-4bba62eb8de961cbfc0ba53cd26b9667db551748.tar.gz
plack-middleware-xslate-4bba62eb8de961cbfc0ba53cd26b9667db551748.zip
basic test
-rw-r--r--t/basic.t44
-rw-r--r--t/basic/index.html4
-rw-r--r--t/basic/wrapper.tx10
3 files changed, 58 insertions, 0 deletions
diff --git a/t/basic.t b/t/basic.t
new file mode 100644
index 0000000..a7f66b4
--- /dev/null
+++ b/t/basic.t
@@ -0,0 +1,44 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Plack::Test;
+
+use HTTP::Request::Common;
+use Plack::Builder;
+
+my $app = builder {
+ enable "Xslate",
+ path => qr{^/}, root => 't/basic/', pass_through => 1;
+ sub { [ 404, [], [ 'Not found' ] ] };
+};
+
+test_psgi
+ app => $app,
+ client => sub {
+ my $cb = shift;
+
+ {
+ my $res = $cb->(GET '/index.html');
+ ok($res->is_success) || diag($res->content);
+ is($res->content, <<'CONTENT');
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<link rel="stylesheet" type="text/css" href="/style.css" />
+</head>
+<body>
+<h1>Hello world</h1>
+</body>
+</html>
+CONTENT
+ }
+
+ {
+ my $res = $cb->(GET '/missing.html');
+ is($res->code, 404);
+ }
+ };
+
+done_testing;
diff --git a/t/basic/index.html b/t/basic/index.html
new file mode 100644
index 0000000..8518a6a
--- /dev/null
+++ b/t/basic/index.html
@@ -0,0 +1,4 @@
+: cascade 'wrapper.tx'
+: override content -> {
+<h1>Hello world</h1>
+: }
diff --git a/t/basic/wrapper.tx b/t/basic/wrapper.tx
new file mode 100644
index 0000000..5739c50
--- /dev/null
+++ b/t/basic/wrapper.tx
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<link rel="stylesheet" type="text/css" href="/style.css" />
+</head>
+<body>
+: block content -> { }
+</body>
+</html>