File: new.t

package info (click to toggle)
libwww-mechanize-perl 1.18-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 488 kB
  • ctags: 109
  • sloc: perl: 2,315; makefile: 39
file content (45 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (2)
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
#!perl -Tw

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

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

RES_ON_NEW: {
    my $m = WWW::Mechanize->new;
    isa_ok( $m, 'WWW::Mechanize' );

    ok( !$m->success, "success() is false before any get" );

    my $res = $m->res;
    ok( !defined $res, "res() is undef" );
}


NO_AGENT: {
    my $m = WWW::Mechanize->new;
    isa_ok( $m, 'WWW::Mechanize' );
    can_ok( $m, 'request' );
    like( $m->agent, qr/WWW-Mechanize/, "Set user agent string" );
    like( $m->agent, qr/$WWW::Mechanize::VERSION/, "Set user agent version" );

    $m->agent( "foo/bar v1.23" );
    is( $m->agent, "foo/bar v1.23", "Can set the agent" );
}

USER_AGENT: {
    my $alias = "Windows IE 6";
    my $m = WWW::Mechanize->new( agent => $alias );
    isa_ok( $m, 'WWW::Mechanize' );
    can_ok( $m, 'request' );
    is( $m->agent, $alias, "Aliases don't get translated in the constructor" );

    $m->agent_alias( $alias );
    like( $m->agent, qr/^Mozilla.+compatible.+Windows/, "Alias sets the agent" ); 

    $m->agent( "ratso/bongo v.43" );
    is( $m->agent, "ratso/bongo v.43", "Can still set the agent" );
}