forked from metacpan/metacpan-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.t
30 lines (27 loc) · 1017 Bytes
/
module.t
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
use strict;
use warnings;
use Test::More;
use MetaCPAN::Web::Test;
test_psgi app, sub {
my $cb = shift;
ok( my $res = $cb->( GET "/module/DOESNTEXIST" ),
'GET /module/DOESNTEXIST' );
is( $res->code, 404, 'code 404' );
ok( $res = $cb->( GET "/module/Moose" ), 'GET /module/Moose' );
is( $res->code, 200, 'code 200' );
my $tx = tx($res);
$tx->like( '/html/head/title', qr/Moose/, 'title includes Moose' );
ok( $tx->find_value('//a[@href="/module/Moose"]'),
'contains permalink to resource'
);
ok( my $this = $tx->find_value('//a[text()="This version"]/@href'),
'contains link to "this" version' );
my $latest = $res->content;
ok( $res = $cb->( GET $this ), "GET $this" );
is($latest, $res->content, 'content of both urls is exactly the same');
# get module with lc author
$this =~ s{(/module/.*?/)}{lc($1)}e; # lc author name
ok( $res = $cb->( GET $this ), "GET $this" );
is( $res->code, 301, 'code 301' );
};
done_testing;