Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7f94bd0683
Fetching contributors…

Cannot retrieve contributors at this time

59 lines (48 sloc) 1.779 kb
#!perl -Tw
use strict;
use warnings;
use Test::Builder::Tester;
use Test::More;
use URI::file;
BEGIN {
eval 'use HTML::Lint';
plan skip_all => 'HTML::Lint is not installed, cannot test autolint' if $@;
plan tests => 7;
}
BEGIN {
use_ok( 'Test::WWW::Mechanize' );
}
GOOD_GET_GOOD_HTML: {
my $mech = Test::WWW::Mechanize->new( autolint => 1 );
isa_ok( $mech, 'Test::WWW::Mechanize' );
my $uri = URI::file->new_abs( 't/good.html' )->as_string;
$mech->get_ok( $uri );
test_out( "ok 1 - GET $uri" );
$mech->get_ok( $uri, "GET $uri" );
test_test( 'Good GET, good HTML' );
}
GOOD_GET_BAD_HTML: {
my $mech = Test::WWW::Mechanize->new( autolint => 1 );
isa_ok( $mech, 'Test::WWW::Mechanize' );
my $uri = URI::file->new_abs( 't/bad.html' )->as_string;
# Test via get_ok
test_out( "not ok 1 - GET $uri" );
test_fail( +6 );
test_err( "# HTML::Lint errors for $uri" );
test_err( '# (7:9) Unknown attribute "hrex" for tag <a>' );
test_err( '# (8:33) </b> with no opening <b>' );
test_err( '# (9:5) <a> at (8:9) is never closed' );
test_err( '# 3 errors on the page' );
$mech->get_ok( $uri, "GET $uri" );
test_test( 'get_ok complains about bad HTML' );
# Test via follow_link_ok
test_out( 'not ok 1 - Following link back to bad.html' );
test_fail( +6 );
test_err( "# HTML::Lint errors for $uri" );
test_err( '# (7:9) Unknown attribute "hrex" for tag <a>' );
test_err( '# (8:33) </b> with no opening <b>' );
test_err( '# (9:5) <a> at (8:9) is never closed' );
test_err( '# 3 errors on the page' );
$mech->follow_link_ok( { text => 'Back to bad' }, 'Following link back to bad.html' );
test_test( 'follow_link_ok complains about bad HTML' );
}
Jump to Line
Something went wrong with that request. Please try again.