File: reload.t

package info (click to toggle)
libwww-mechanize-perl 1.34-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 532 kB
  • ctags: 122
  • sloc: perl: 2,747; makefile: 43
file content (54 lines) | stat: -rw-r--r-- 1,243 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!perl

use warnings;
use strict;
use Test::More tests => 14;

use lib 't/local';
use LocalServer;

BEGIN {
    delete @ENV{ grep { lc eq 'http_proxy' } keys %ENV };
    delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) };
    use_ok( 'WWW::Mechanize' );
}

my $server = LocalServer->spawn;
isa_ok( $server, 'LocalServer' );

my $agent = WWW::Mechanize->new;
isa_ok( $agent, 'WWW::Mechanize', 'Created object' );

NO_GET: {
    my $r = $agent->reload;
    ok( !defined($r), 'Initial reload should fail' );
}

FIRST_GET: {
    my $r = $agent->get($server->url);
    isa_ok( $r, 'HTTP::Response' );
    ok( $r->is_success, 'Get google webpage');
    ok( $agent->is_html, 'Valid HTML' );
    is( $agent->title, 'WWW::Mechanize::Shell test page' );
}

INVALIDATE: {
    undef $agent->{content};
    undef $agent->{ct};
    isnt( $agent->title, 'WWW::Mechanize::Shell test page' );
    ok( !$agent->is_html, 'Not HTML' );
}

RELOAD: {
    my $r = $agent->reload;
    isa_ok( $r, 'HTTP::Response' );
    ok( $agent->is_html, 'Valid HTML' );
    ok( $agent->title, 'WWW::Mechanize::Shell test page' );
}

SKIP: {
    eval 'use Test::Memory::Cycle';
    skip 'Test::Memory::Cycle not installed', 1 if $@;

    memory_cycle_ok( $agent, 'Mech: no cycles' );
}