6 use Test::More tests => 37;
8 use Test::WWW::Mechanize::Catalyst 'Catty';
10 my $root = "http://localhost";
12 my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 );
15 is( $m->ct, "text/html" );
17 $m->content_contains("This is the root page");
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 my $bytes = "Hi there! ☺";
24 my $chars = Encode::decode( 'utf-8', $bytes );
25 $m->content_contains( $chars, qq{content contains "$bytes"});
27 #use Devel::Peek; Dump $m->content;
28 #Dump(Encode::decode('utf-8', "Hi there! ☺"));
32 is( $m->ct, "text/html" );
34 $m->content_contains("This is the root page");
36 $m->get_ok("http://example.com/");
37 is( $m->ct, "text/html" );
39 $m->content_contains("This is the root page");
41 $m->get_ok("/hello/");
42 is( $m->ct, "text/html" );
43 $m->title_is("Hello");
44 $m->content_contains( $chars, qq{content contains "$bytes"});
47 eval { require Compress::Zlib; };
48 skip "Compress::Zlib needed to test gzip encoding", 4 if $@;
49 $m->get_ok("/gzipped/");
50 is( $m->ct, "text/html" );
51 $m->title_is("Hello");
52 $m->content_contains( $chars, qq{content contains "$bytes"});
55 $m->get("$root/die/");
56 is( $m->status, 500 );
57 $m->content_like( qr!\(en\) Please come back later!);
58 $m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
61 is( $m->status, 500 );
62 $m->content_like( qr!\(en\) Please come back later!);
63 $m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
66 no warnings 'redefine';
67 ${Catty::}{debug} = sub { 1 };
68 $m->{catalyst_debug} = 1;
69 $m->get("$root/die/");
70 is( $m->status, 500 );
71 is( $m->ct, "text/html" );
72 $m->title_like(qr/Catty on Catalyst/);
73 $m->content_like(qr/Caught exception in Catty/);
74 $m->content_like(qr/erk/);
75 $m->content_like(qr/This is the die page/);