X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fmulti_content_type.t;h=4fb0a2546d27e197273033dbc3e7fc25c6681b89;hb=64c13f8ec0dbc19d03972d7bfb39ac89e558cddc;hp=6fbdaa4652269daba9b87dcb1457684f4c09048f;hpb=ab0b00e34c84030a407adce9be1a94c66b946fa5;p=catagits%2FTest-WWW-Mechanize-Catalyst.git diff --git a/t/multi_content_type.t b/t/multi_content_type.t index 6fbdaa4..4fb0a25 100644 --- a/t/multi_content_type.t +++ b/t/multi_content_type.t @@ -10,7 +10,7 @@ BEGIN { $ENV{CATALYST_SERVER} ||= "http://localhost:$PORT"; } -use Test::More tests => 6; +use Test::More tests => 9; use Test::Exception; BEGIN { @@ -32,15 +32,35 @@ my $pid = ExternalCatty->background($PORT); use Test::WWW::Mechanize::Catalyst; my $m = Test::WWW::Mechanize::Catalyst->new; -lives_ok { $m->get_ok( '/', 'Get a multi Content-Type response' ) } -'Survive to a multi Content-Type sting'; +my $skip = 0; +TRY_CONNECT: { + eval { $m->get('/') }; -is( $m->ct, 'text/html', 'Multi Content-Type Content-Type' ); -$m->title_is( 'Root', 'Multi Content-Type title' ); -$m->content_contains( "Hello, test \x{263A}!", 'Multi Content-Type body' ); + if ($@ || $m->content =~ /Can't connect to \w+:$PORT/) { + $skip = $@ || $m->content; + } +} + +SKIP: { + skip $skip, 8 if $skip; + lives_ok { $m->get_ok( '/', 'Get a multi Content-Type response' ) } + 'Survive to a multi Content-Type sting'; + + is( $m->ct, 'text/html', 'Multi Content-Type Content-Type' ); + $m->title_is( 'Root', 'Multi Content-Type title' ); + $m->content_contains( "Hello, test \x{263A}!", 'Multi Content-Type body' ); + + # Test a redirect with a remote server now too. + $m->get_ok( '/hello' ); + is($m->uri, "$ENV{CATALYST_SERVER}/"); + + $m->get_ok( '/host' ); + $m->content_contains('Host: localhost:$PORT') or diag $m->content; + +} END { - if ( $pid > 0 ) { + if ( $pid && $pid != 0 ) { kill 9, $pid; } }