File: follow_link_ok.t

package info (click to toggle)
libtest-www-mechanize-perl 1.30-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 252 kB
  • ctags: 52
  • sloc: perl: 1,617; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!perl

use strict;
use warnings;
use Test::More tests => 5;
use Test::Builder::Tester;

BEGIN {
    use_ok( 'Test::WWW::Mechanize' );
}

use lib 't';
use TestServer;

my $server      = TestServer->new;
my $pid         = $server->background;
my $server_root = $server->root;

FOLLOW_GOOD_LINK: {
    my $mech = Test::WWW::Mechanize->new( autocheck => 0 );
    isa_ok( $mech,'Test::WWW::Mechanize' );

    $mech->get( "$server_root/goodlinks.html" );
    $mech->follow_link_ok( {n=>1}, 'Go after first link' );
}

FOLLOW_BAD_LINK: {
    my $mech = Test::WWW::Mechanize->new( autocheck => 0 );
    isa_ok( $mech, 'Test::WWW::Mechanize' );
    local $TODO = q{I don't know how to get Test::Builder::Tester to handle regexes for the timestamp.};

    $mech->get( "$server_root/badlinks.html" );
    test_out('not ok 1 - Go after bad link');
    test_fail(+1);
    $mech->follow_link_ok( {n=>2}, 'Go after bad link' );
    test_diag('');
    test_test('Handles bad links');
}

$server->stop;