Skip to content

Commit

Permalink
done with the autolint on get_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Dec 22, 2008
1 parent 7474c81 commit 77fab29
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Mechanize.pm
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ https links.
sub followable_links {
my $self = shift;

return $self->find_all_links( url_abs_regex => qr[^https?://] );
return $self->find_all_links( url_abs_regex => qr{^https?://} );
}

=head2 $mech->page_links_ok( [ $desc ] )
Expand Down
1 change: 1 addition & 0 deletions perlcriticrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ modules = Autoload Data::Dumper Date::Manip /Acme::/ Array::Iterator Carp::Alway

[-Modules::RequireVersionVar]

[-RegularExpressions::RequireDotMatchAnything]
[-RegularExpressions::RequireExtendedFormatting]
[-RegularExpressions::RequireLineBoundaryMatching]

Expand Down
2 changes: 1 addition & 1 deletion t/TestServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sub handle_request {
my $self = shift;
my $cgi = shift;

my $file = (split('/',$cgi->path_info))[-1]||'index.html';
my $file = (split( /\//,$cgi->path_info))[-1]||'index.html';
$file =~ s/\s+//g;

my $filename = "t/html/$file";
Expand Down
8 changes: 5 additions & 3 deletions t/autolint.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Test::More;
BEGIN {
eval 'use HTML::Lint';
plan skip_all => 'HTML::Lint is not installed, cannot test autolint' if $@;
plan tests => 4;
plan tests => 7;
}

BEGIN {
Expand Down Expand Up @@ -40,12 +40,14 @@ GOOD_GET_BAD_HTML: {
my $uri = "$server_root/bad.html";

test_out( 'not ok 1 - GET bad.html' );
test_fail( +5 );
test_fail( +8 );
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' );
test_diag( '200' );
test_diag( 'OK' );
$mech->get_ok( $uri, 'GET bad.html' );
test_test( 'Good GET, bad HTML' );
}
Expand All @@ -59,7 +61,7 @@ BAD_GET: {
test_out( 'not ok 1 - GET nonexistent.html' );
test_fail( +3 );
test_diag( '404' );
test_diag( qq{File `$uri' does not exist} );
test_diag( 'Not Found' );
$mech->get_ok( $uri, 'GET nonexistent.html' );
test_test( 'Bad GET' );
}
Expand Down
16 changes: 8 additions & 8 deletions t/get_ok.t
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ GOOD_GET: {
test_out('ok 1 - Try to get goodlinks.html');
my $ok = $mech->get_ok($goodlinks, 'Try to get goodlinks.html');
test_test('Gets existing URI and reports success');
is( ref($ok), '', "get_ok() should only return a scalar" );
ok( $ok, "And the result should be true" );
is( ref($ok), '', 'get_ok() should only return a scalar' );
ok( $ok, 'And the result should be true' );

# default desc
test_out("ok 1 - GET $goodlinks");
Expand All @@ -48,19 +48,19 @@ GOOD_GET: {
}

BAD_GET: {
my $badurl = "http://wango.nonexistent.xx-only-testing/";
my $badurl = 'http://wango.nonexistent.xx-only-testing/';
$mech->get($badurl);
ok(!$mech->success, "sanity check: we can't load NONEXISTENT.html");
ok(!$mech->success, q{sanity check: we can't load NONEXISTENT.html});

test_out( 'not ok 1 - Try to get bad URL' );
test_fail( +3 );
test_diag( "500" );
test_diag( "Can't connect to wango.nonexistent.xx-only-testing:80 (Bad hostname 'wango.nonexistent.xx-only-testing')" );
test_diag( '500' );
test_diag( q{Can't connect to wango.nonexistent.xx-only-testing:80 (Bad hostname 'wango.nonexistent.xx-only-testing')} );
my $ok = $mech->get_ok( $badurl, 'Try to get bad URL' );
test_test( 'Fails to get nonexistent URI and reports failure' );

is( ref($ok), '', "get_ok() should only return a scalar" );
ok( !$ok, "And the result should be false" );
is( ref($ok), '', 'get_ok() should only return a scalar' );
ok( !$ok, 'And the result should be false' );
}

$server->stop;
3 changes: 3 additions & 0 deletions tags
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.7 //
BAD_GET t/autolint.t /^BAD_GET: {$/;" l
BAD_GET t/back_ok.t /^BAD_GET: {$/;" l
BAD_GET t/get_ok.t /^BAD_GET: {$/;" l
BAD_HEAD t/head_ok.t /^BAD_HEAD: {$/;" l
Expand All @@ -16,6 +17,8 @@ FOLLOW_GOOD_LINK t/follow_link_ok.t /^FOLLOW_GOOD_LINK: {$/;" l
GOOD_GET t/back_ok.t /^GOOD_GET: {$/;" l
GOOD_GET t/get_ok.t /^GOOD_GET: {$/;" l
GOOD_GET t/html_lint_ok.t /^GOOD_GET: {$/;" l
GOOD_GET_BAD_HTML t/autolint.t /^GOOD_GET_BAD_HTML: {$/;" l
GOOD_GET_GOOD_HTML t/autolint.t /^GOOD_GET_GOOD_HTML: {$/;" l
GOOD_HEAD t/head_ok.t /^GOOD_HEAD: { # Stop giggling, you!$/;" l
GOOD_PUT t/put_ok.t /^GOOD_PUT: {$/;" l
IGNORE t/stuff_inputs.t /^IGNORE: {$/;" l
Expand Down

0 comments on commit 77fab29

Please sign in to comment.