6 use Test::More tests => 37;
9 $ENV{CATALYST_DEBUG} = 0;
10 $ENV{CATTY_DEBUG} = 0;
12 use Test::WWW::Mechanize::Catalyst 'Catty';
14 my $root = "http://localhost";
16 my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 );
19 is( $m->ct, "text/html" );
21 $m->content_contains("This is the root page");
23 $m->follow_link_ok( { text => 'Hello' } );
24 is( $m->base, "http://localhost/hello/" );
25 is( $m->ct, "text/html" );
26 $m->title_is("Hello");
27 my $bytes = "Hi there! ☺";
28 my $chars = Encode::decode( 'utf-8', $bytes );
29 $m->content_contains( $chars, qq{content contains "$bytes"});
31 #use Devel::Peek; Dump $m->content;
32 #Dump(Encode::decode('utf-8', "Hi there! ☺"));
36 is( $m->ct, "text/html" );
38 $m->content_contains("This is the root page");
40 $m->get_ok("http://example.com/");
41 is( $m->ct, "text/html" );
43 $m->content_contains("This is the root page");
45 $m->get_ok("/hello/");
46 is( $m->ct, "text/html" );
47 $m->title_is("Hello");
48 $m->content_contains( $chars, qq{content contains "$bytes"});
51 eval { require Compress::Zlib; };
52 skip "Compress::Zlib needed to test gzip encoding", 4 if $@;
53 $m->get_ok("/gzipped/");
54 is( $m->ct, "text/html" );
55 $m->title_is("Hello");
56 $m->content_contains( $chars, qq{content contains "$bytes"});
59 $m->get("$root/die/");
60 is( $m->status, 500 );
61 $m->content_like( qr!\(en\) Please come back later!);
62 $m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
65 is( $m->status, 500 );
66 $m->content_like( qr!\(en\) Please come back later!);
67 $m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
70 no warnings 'redefine';
71 ${Catty::}{debug} = sub { 1 };
72 $m->{catalyst_debug} = 1;
73 $m->get("$root/die/");
74 is( $m->status, 500 );
75 is( $m->ct, "text/html" );
76 $m->title_like(qr/Catty on Catalyst/);
77 $m->content_like(qr/Caught exception in Catty/);
78 $m->content_like(qr/erk/);
79 $m->content_like(qr/This is the die page/);