[Bps-public-commit] r11925 - in HTML-RewriteResources: .
sartak at bestpractical.com
sartak at bestpractical.com
Mon Apr 28 19:43:09 EDT 2008
Author: sartak
Date: Mon Apr 28 19:43:09 2008
New Revision: 11925
Added:
HTML-RewriteResources/t/
HTML-RewriteResources/t/001-basic.t
Modified:
HTML-RewriteResources/ (props changed)
Log:
r54596 at onn: sartak | 2008-04-28 19:21:00 -0400
Sketch out the interface with a test script
Added: HTML-RewriteResources/t/001-basic.t
==============================================================================
--- (empty file)
+++ HTML-RewriteResources/t/001-basic.t Mon Apr 28 19:43:09 2008
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use HTML::RewriteResources;
+use Test::More tests => 4;
+
+my $html = << "END";
+<html>
+ <body>
+ <img src="moose.jpg" />
+ <img src="http://example.com/nethack.png">
+ </body>
+</html>
+END
+
+my %seen;
+
+my $rewrote = HTML::RewriteResources->rewrite($html, sub {
+ my $uri = shift;
+ $seen{$uri}++;
+ return uc $uri;
+});
+
+is(keys %seen, 2, "saw two resources");
+is($seen{"moose.jpg"}, 1, "saw moose.jpg once");
+is($seen{"http://example.com/nethack.png"}, 1, "saw http://example.com/nethack.png once");
+
+is($rewrote, << "END", "rewrote the html correctly");
+<html>
+ <body>
+ <img src="MOOSE.JPG" />
+ <img src="HTTP://EXAMPLE.COM/NETHACK.PNG">
+ </body>
+</html>
+END
+
More information about the Bps-public-commit
mailing list