Commit | Line | Data |
6bc86362 |
1 | #!perl -T |
2 | use strict; |
3 | use warnings; |
4 | use lib 'lib'; |
5 | use Encode qw(); |
6 | use Test::More tests => 39; |
7 | use lib 't/lib'; |
8 | use Test::WWW::Mechanize::Catalyst 'Catty'; |
9 | |
10 | my $root = "http://localhost"; |
11 | |
12 | my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 ); |
13 | |
14 | $m->get_ok("$root/"); |
15 | is( $m->ct, "text/html" ); |
16 | $m->title_is("Root"); |
17 | $m->content_contains("This is the root page"); |
18 | |
19 | $m->follow_link_ok( { text => 'Hello' } ); |
20 | is( $m->base, "http://localhost/hello/" ); |
21 | is( $m->ct, "text/html" ); |
22 | $m->title_is("Hello"); |
23 | $m->content_contains( Encode::decode( 'utf-8', "Hi there! ☺" ) ); |
24 | |
25 | #use Devel::Peek; Dump $m->content; |
26 | #Dump(Encode::decode('utf-8', "Hi there! ☺")); |
27 | #exit; |
28 | |
29 | $m->get_ok("/"); |
30 | is( $m->ct, "text/html" ); |
31 | $m->title_is("Root"); |
32 | $m->content_contains("This is the root page"); |
33 | |
34 | $m->get_ok("http://example.com/"); |
35 | is( $m->ct, "text/html" ); |
36 | $m->title_is("Root"); |
37 | $m->content_contains("This is the root page"); |
38 | |
39 | $m->get_ok("/hello/"); |
40 | is( $m->ct, "text/html" ); |
41 | $m->title_is("Hello"); |
42 | $m->content_contains( Encode::decode( 'utf-8', "Hi there! ☺" ) ); |
43 | |
44 | SKIP: { |
45 | eval { require Compress::Zlib; }; |
46 | skip "Compress::Zlib needed to test gzip encoding", 4 if $@; |
47 | $m->get_ok("/gzipped/"); |
48 | is( $m->ct, "text/html" ); |
49 | $m->title_is("Hello"); |
50 | $m->content_contains( Encode::decode( 'utf-8', "Hi there! ☺" ) ); |
51 | } |
52 | |
53 | $m->get("$root/die/"); |
54 | is( $m->status, 500 ); |
55 | is( $m->ct, "" ); |
56 | $m->title_is(undef); |
57 | $m->content_is(""); |
58 | |
59 | $m->get("/die/"); |
60 | is( $m->status, 500 ); |
61 | is( $m->ct, "" ); |
62 | $m->title_is(undef); |
63 | $m->content_is(""); |
64 | |
65 | $m->{catalyst_debug} = 1; |
66 | $m->get("$root/die/"); |
67 | is( $m->status, 500 ); |
68 | is( $m->ct, "text/html" ); |
69 | $m->title_like(qr/Catty on Catalyst/); |
70 | $m->content_like(qr/Caught exception in Catty/); |
71 | $m->content_like(qr/erk/); |
72 | $m->content_like(qr/This is the die page/); |
73 | |