summaryrefslogtreecommitdiffstats
path: root/t/safestring.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-10-02 15:11:59 -0500
committerJesse Luehrs <doy@tozt.net>2012-10-02 15:31:20 -0500
commitf8163f38482ebe4a48b08a3f49080821e62e383b (patch)
tree83398b2cd786e538487d13e4d50a547d91b0bbbf /t/safestring.t
parent5dc5000f75492b6f78d27fab3c56055d4534b5a7 (diff)
downloadtext-handlebars-f8163f38482ebe4a48b08a3f49080821e62e383b.tar.gz
text-handlebars-f8163f38482ebe4a48b08a3f49080821e62e383b.zip
refactor tests
Diffstat (limited to 't/safestring.t')
-rw-r--r--t/safestring.t58
1 files changed, 40 insertions, 18 deletions
diff --git a/t/safestring.t b/t/safestring.t
index 27d9ac1..29ec4ec 100644
--- a/t/safestring.t
+++ b/t/safestring.t
@@ -1,35 +1,57 @@
#!/usr/bin/env perl
use strict;
use warnings;
+use lib 't/lib';
use Test::More;
+use Test::Handlebars;
-use Text::Handlebars;
use Text::Xslate 'mark_raw';
-my $tx = Text::Handlebars->new;
-
-is(
- $tx->render_string(
- '<h1>{{title}}</h1><p>{{{body}}}</p>',
- { title => 'My New Post', body => 'This is my first post!' },
- ),
+render_ok(
+ '<h1>{{title}}</h1><p>{{{body}}}</p>',
+ { title => 'My New Post', body => 'This is my first post!' },
'<h1>My New Post</h1><p>This is my first post!</p>',
+ "raw body",
);
-is(
- $tx->render_string(
- '<h1>{{title}}</h1><p>{{{body}}}</p>',
- { title => 'All About <p> Tags', body => '<i>This is a post about &lt;p&gt; tags</i>' },
- ),
+render_ok(
+ '<h1>{{title}}</h1><p>{{{body}}}</p>',
+ {
+ title => 'All About <p> Tags',
+ body => '<i>This is a post about &lt;p&gt; tags</i>'
+ },
'<h1>All About &lt;p&gt; Tags</h1><p><i>This is a post about &lt;p&gt; tags</i></p>',
+ "raw body with html"
);
-is(
- $tx->render_string(
- '<h1>{{title}}</h1><p>{{{body}}}</p>',
- { title => mark_raw('All About &lt;p&gt; Tags'), body => '<i>This is a post about &lt;p&gt; tags</i>' },
- ),
+render_ok(
+ '<h1>{{title}}</h1><p>{{{body}}}</p>',
+ {
+ title => mark_raw('All About &lt;p&gt; Tags'),
+ body => '<i>This is a post about &lt;p&gt; tags</i>'
+ },
'<h1>All About &lt;p&gt; Tags</h1><p><i>This is a post about &lt;p&gt; tags</i></p>',
+ "raw title with manual mark_raw() call"
+);
+
+render_ok(
+ <<'TEMPLATE',
+* {{name}}
+* {{age}}
+* {{company}}
+* {{& company}}
+TEMPLATE
+ {
+ name => 'Chris',
+ company => '<b>GitHub</b>',
+ },
+ <<'RENDERED',
+* Chris
+*
+* &lt;b&gt;GitHub&lt;/b&gt;
+* <b>GitHub</b>
+RENDERED
+ "mark_raw via &"
);
done_testing;