Make test less noisy by removing -Debug and cleaning up wide charin print errors
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / simple.t
CommitLineData
db8bd5bb 1#!perl
6bc86362 2use strict;
3use warnings;
4use lib 'lib';
5use Encode qw();
db8bd5bb 6use Test::More tests => 37;
6bc86362 7use lib 't/lib';
8use Test::WWW::Mechanize::Catalyst 'Catty';
9
10my $root = "http://localhost";
11
12my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 );
13
14$m->get_ok("$root/");
15is( $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' } );
20is( $m->base, "http://localhost/hello/" );
21is( $m->ct, "text/html" );
22$m->title_is("Hello");
db8bd5bb 23my $bytes = "Hi there! ☺";
24my $chars = Encode::decode( 'utf-8', $bytes );
25$m->content_contains( $chars, qq{content contains "$bytes"});
6bc86362 26
27#use Devel::Peek; Dump $m->content;
28#Dump(Encode::decode('utf-8', "Hi there! ☺"));
29#exit;
30
31$m->get_ok("/");
32is( $m->ct, "text/html" );
33$m->title_is("Root");
34$m->content_contains("This is the root page");
35
36$m->get_ok("http://example.com/");
37is( $m->ct, "text/html" );
38$m->title_is("Root");
39$m->content_contains("This is the root page");
40
41$m->get_ok("/hello/");
42is( $m->ct, "text/html" );
43$m->title_is("Hello");
db8bd5bb 44$m->content_contains( $chars, qq{content contains "$bytes"});
6bc86362 45
46SKIP: {
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");
db8bd5bb 52 $m->content_contains( $chars, qq{content contains "$bytes"});
6bc86362 53}
54
55$m->get("$root/die/");
56is( $m->status, 500 );
db8bd5bb 57$m->content_like( qr!\(en\) Please come back later!);
58$m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
6bc86362 59
60$m->get("/die/");
61is( $m->status, 500 );
db8bd5bb 62$m->content_like( qr!\(en\) Please come back later!);
63$m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
6bc86362 64
db8bd5bb 65{
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/);
76}