Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

version 2.01 - more resilent tests

  • Loading branch information...
commit 2e36524fb9286b2f17cf7ead64988501dd747a04 1 parent 4c27b07
@2shortplanks authored
View
2  CHANGES
@@ -1,3 +1,5 @@
+2.01 Further improvements to make test suite less brittle
+
2.00 Fixed text failures to do with new version of Text::Textile
Moved to Module::Install, added standard kwalitee tests, etc
View
2  META.yml
@@ -25,4 +25,4 @@ resources:
homepage: http://github.com/2shortplanks/Template-Plugin-Textile/tree
license: http://dev.perl.org/licenses/
repository: git://github.com/2shortplanks/Template-Plugin-Textile.git
-version: 2.00
+version: 2.01
View
2  lib/Template/Plugin/Textile.pm
@@ -4,7 +4,7 @@ use strict;
#use warnings;
use vars qw($VERSION);
-$VERSION = "2.00";
+$VERSION = "2.01";
use Text::Textile;
View
55 t/01basic.t
@@ -1,41 +1,40 @@
#!/usr/bin/perl
use strict;
+use Test::More tests => 3;
+use Text::Textile qw(textile);
+use Template;
-use Template::Test;
-test_expect(\*DATA);
-
-__DATA__
--- test --
-[% USE Textile -%]
-[% FILTER textile %]this is _like_ *so* *cool*[% END %]
--- expect --
-<p>this is <em>like</em> <strong>so</strong> <strong>cool</strong></p>
--- test --
-[% FILTER textile -%]
+
+test("this is _like_ *so* *cool*", "basic");
+
+test(<<'ENDOFTEMPLATE', "bigger");
Reasons to use the Template Toolkit:
* Seperation of concerns.
* It's written in Perl.
* Badgers are Still Cool.
-[%- END %]
--- expect --
-<p>Reasons to use the Template Toolkit:</p>
-
-<ul>
-<li>Seperation of concerns.</li>
-<li>It&#39;s written in Perl.</li>
-<li>Badgers are Still Cool.</li>
-</ul>
--- test --
-[% text = BLOCK %]
+ENDOFTEMPLATE
+
+test(<<'ENDOFTEMPLATE', "biggest");
The "Template Toolkit":http://www.tt2.org was written by Andy Wardly.
!http://www.perl.com/supersnail/os2002/images/small/os6_d5_5268_w2_sm.jpg!
This image (c) Julian Cash 2002
-[% END -%]
+ENDOFTEMPLATE
+
+sub test {
+ my $source = shift;
+ my $desc = shift;
+
+ # make errors come from the right place
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my $src = '[% USE Textile %][% FILTER textile %]'.$source.'[% END %]';
+ my $output = "";
+ my $tt = Template->new();
+ unless ($tt->process(\$src, {}, \$output)) {
+ $output = $tt->error;
+ }
-[%- text | textile %]
--- expect --
-<p>The <a href="http://www.tt2.org">Template Toolkit</a> was written by Andy Wardly.<br />
-<img src="http://www.perl.com/supersnail/os2002/images/small/os6_d5_5268_w2_sm.jpg" alt="" />
-This image &#169; Julian Cash 2002</p>
+ is($output, textile($source), $desc);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.