[Bps-public-commit] r11943 - in HTML-RewriteAttributes: .
sartak at bestpractical.com
sartak at bestpractical.com
Mon Apr 28 21:54:50 EDT 2008
Author: sartak
Date: Mon Apr 28 21:54:39 2008
New Revision: 11943
Added:
HTML-RewriteAttributes/t/002-resources.t
HTML-RewriteAttributes/t/003-links.t
Modified:
HTML-RewriteAttributes/ (props changed)
Log:
r54627 at onn: sartak | 2008-04-28 21:54:13 -0400
Basic tests for ::Resources and ::Links
Added: HTML-RewriteAttributes/t/002-resources.t
==============================================================================
--- (empty file)
+++ HTML-RewriteAttributes/t/002-resources.t Mon Apr 28 21:54:39 2008
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use HTML::RewriteAttributes::Resources;
+use Test::More tests => 2;
+
+my $html = << "END";
+<html>
+ <body>
+ <img src="moose.jpg" />
+ <img src="http://example.com/nethack.png">
+ <p align="justified" style="color: red">
+ hooray
+ </p>
+ </body>
+</html>
+END
+
+my @seen;
+
+my $rewrote = HTML::RewriteAttributes::Resources->rewrite($html, sub {
+ my $uri = shift;
+ my %args = @_;
+
+ push @seen, [$uri, $args{tag}, $args{attr}];
+
+ return reverse $uri;
+});
+
+is_deeply(\@seen, [
+ ["moose.jpg" => img => "src"],
+ ["http://example.com/nethack.png" => img => "src"],
+]);
+
+is($rewrote, << "END", "rewrote the html correctly");
+<html>
+ <body>
+ <img src="gpj.esoom" />
+ <img src="gnp.kcahten/moc.elpmaxe//:ptth">
+ <p align="justified" style="color: red">
+ hooray
+ </p>
+ </body>
+</html>
+END
+
Added: HTML-RewriteAttributes/t/003-links.t
==============================================================================
--- (empty file)
+++ HTML-RewriteAttributes/t/003-links.t Mon Apr 28 21:54:39 2008
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use HTML::RewriteAttributes::Links;
+use Test::More tests => 1;
+
+my $html = << "END";
+<html>
+ <body>
+ <img src="moose.jpg" />
+ <img src="http://example.com/nethack.png">
+ <p align="justified" style="color: red">
+ hooray
+ </p>
+ </body>
+</html>
+END
+
+my $rewrote = HTML::RewriteAttributes::Links->rewrite($html, "http://cpan.org");
+
+is($rewrote, << "END", "rewrote the html correctly");
+<html>
+ <body>
+ <img src="http://cpan.org/moose.jpg" />
+ <img src="http://example.com/nethack.png">
+ <p align="justified" style="color: red">
+ hooray
+ </p>
+ </body>
+</html>
+END
+
More information about the Bps-public-commit
mailing list