Checking in changes prior to tagging of version 1.000. Changelog diff is:
[catagits/Catalyst-View-ContentNegotiation-XHTML.git] / t / live-test.t
CommitLineData
0f9bcf09 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use Test::More tests => 13;
6
7# setup library path
8use FindBin qw($Bin);
9use lib "$Bin/lib";
10
11# 1 make sure testapp works
cd25b1db 12use_ok 'TestApp';
0f9bcf09 13
14# a live test against TestApp, the test application
15use Test::WWW::Mechanize::Catalyst 'TestApp';
16my $mech = Test::WWW::Mechanize::Catalyst->new;
17
18# 2-4
19$mech->get_ok('http://localhost/', 'get main page');
20$mech->content_like(qr/it works/i, 'see if it has our text');
21is $mech->response->headers->{'content-type'}, 'text/html; charset=utf-8',
22 'No Accept header = text/html';
23
24$mech->add_header( Accept => 'text/html' );
25
26# 5-7
27$mech->get_ok('http://localhost/', 'get main page');
28$mech->content_like(qr/it works/i, 'see if it has our text');
29is $mech->response->headers->{'content-type'}, 'text/html; charset=utf-8',
30 'Accept header of text/html = text/html';
31
32$mech->add_header( Accept => 'application/xhtml+xml' );
33
34# 8-10
35$mech->get_ok('http://localhost/', 'get main page');
36$mech->content_like(qr/it works/i, 'see if it has our text');
37is $mech->response->headers->{'content-type'}, 'application/xhtml+xml; charset=utf-8',
38 'Accept xhtml gives content type application/xhtml+xml';
39
40# 11-13
41$mech->get_ok('http://localhost/nothtml', 'get nothtml page');
42$mech->content_like(qr/not html/i, 'see if it has our text');
43is $mech->response->headers->{'content-type'}, 'application/json',
44 'application/json is unmolested';