0.60 got released twice because humans suck, fix up the changelog for a 0.61
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / simple.t
CommitLineData
db8bd5bb 1#!perl
6bc86362 2use strict;
3use warnings;
254eca41 4
6bc86362 5use Encode qw();
db8bd5bb 6use Test::More tests => 37;
6bc86362 7use lib 't/lib';
a3b94530 8BEGIN {
9 $ENV{CATALYST_DEBUG} = 0;
10 $ENV{CATTY_DEBUG} = 0;
11}
6bc86362 12use Test::WWW::Mechanize::Catalyst 'Catty';
13
14my $root = "http://localhost";
15
16my $m = Test::WWW::Mechanize::Catalyst->new( autocheck => 0 );
17
18$m->get_ok("$root/");
19is( $m->ct, "text/html" );
20$m->title_is("Root");
21$m->content_contains("This is the root page");
22
23$m->follow_link_ok( { text => 'Hello' } );
24is( $m->base, "http://localhost/hello/" );
25is( $m->ct, "text/html" );
26$m->title_is("Hello");
db8bd5bb 27my $bytes = "Hi there! ☺";
28my $chars = Encode::decode( 'utf-8', $bytes );
29$m->content_contains( $chars, qq{content contains "$bytes"});
6bc86362 30
31#use Devel::Peek; Dump $m->content;
32#Dump(Encode::decode('utf-8', "Hi there! ☺"));
33#exit;
34
35$m->get_ok("/");
36is( $m->ct, "text/html" );
37$m->title_is("Root");
38$m->content_contains("This is the root page");
39
40$m->get_ok("http://example.com/");
41is( $m->ct, "text/html" );
42$m->title_is("Root");
43$m->content_contains("This is the root page");
44
45$m->get_ok("/hello/");
46is( $m->ct, "text/html" );
47$m->title_is("Hello");
db8bd5bb 48$m->content_contains( $chars, qq{content contains "$bytes"});
6bc86362 49
50SKIP: {
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");
db8bd5bb 56 $m->content_contains( $chars, qq{content contains "$bytes"});
6bc86362 57}
58
59$m->get("$root/die/");
60is( $m->status, 500 );
db8bd5bb 61$m->content_like( qr!\(en\) Please come back later!);
62$m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
6bc86362 63
64$m->get("/die/");
65is( $m->status, 500 );
db8bd5bb 66$m->content_like( qr!\(en\) Please come back later!);
67$m->content_unlike( qr!<a href="/hello/">Hello</a>.!);
6bc86362 68
db8bd5bb 69{
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/);
80}