Make t/multi_content_type.t handle case when server cant be started, which is almost...
Ash Berlin [Thu, 12 Feb 2009 09:49:45 +0000 (09:49 +0000)]
CHANGES
Makefile.PL
lib/Test/WWW/Mechanize/Catalyst.pm
t/multi_content_type.t

diff --git a/CHANGES b/CHANGES
index 5be7a7b..5cecf9b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Revision history for Perl module Test::WWW::Mechanize::Catalyst:
 
+0.50_2 Thur Feb 12 09:47 GMT 2008
+     - Make t/multi_content_type.t handle case when server cant be started,
+       which is almost always due to port in use.
+
 0.50_1 Thur Feb 5 09:02 GMT 2008
      - App classname no longer has to be passed to import:
         $m = T::W::M::C->new(catalyst_app => 'Catty')
index 3e50e0a..83e80c7 100644 (file)
@@ -1,5 +1,5 @@
 #!perl
-use inc::Module::Install 0.77;
+use inc::Module::Install 0.79;
 
 use strict;
 use warnings;
index 45bc029..4248f49 100644 (file)
@@ -12,7 +12,7 @@ extends 'Test::WWW::Mechanize', 'Moose::Object';
 
 use namespace::clean -execept => 'meta';
 
-our $VERSION = '0.50_1';
+our $VERSION = '0.50_2';
 our $APP_CLASS;
 my $Test = Test::Builder->new();
 
index 6fbdaa4..081a47e 100644 (file)
@@ -32,15 +32,27 @@ 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 =~ /\(connect: Connection refused\)/) {
+    $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;
     }
 }