X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fmulti_content_type.t;h=71ac22880583a2c07167be5ee5571109fbadc34b;hb=025eaf4a0fd262799c7940e5b65ab58b22435121;hp=2748ebc3b15a239c80de837d8c65f2ff20cc42da;hpb=6bc863629dfa3bec1d938eb5a7af7ef68fd3849f;p=catagits%2FTest-WWW-Mechanize-Catalyst.git diff --git a/t/multi_content_type.t b/t/multi_content_type.t index 2748ebc..71ac228 100644 --- a/t/multi_content_type.t +++ b/t/multi_content_type.t @@ -15,7 +15,7 @@ use Test::Exception; BEGIN { diag( - "###################################################################\n", + "\n###################################################################\n", "Starting an external Catalyst HTTP server on port $PORT\n", "To change the port, please set the TWMC_TEST_PORT env variable.\n", "(The server will be automatically shut-down right after the tests).\n", @@ -29,18 +29,30 @@ $SIG{INT} = sub { warn "INT:$$"; exit }; use_ok 'ExternalCatty'; my $pid = ExternalCatty->background($PORT); -use Test::WWW::Mechanize::Catalyst 'ExternalCatty'; +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 localhost:$PORT/) { + $skip = $@ || $m->content; + } +} + +SKIP: { + skip $skip, 5 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' ); +} END { - if ( $pid > 0 ) { + if ( $pid && $pid != 0 ) { kill 9, $pid; } }