added kmx's patch, still fails
[catagits/Catalyst-Devel.git] / t / generated_app.t
index 3083eaf..0f60949 100644 (file)
@@ -1,7 +1,9 @@
 use strict;
 use warnings;
 
-use File::Temp qw/ tempdir /;
+use File::Temp qw/ tempdir tmpnam /;
+use File::Spec;
+use Test::WWW::Mechanize;
 
 my $dir = tempdir(); # CLEANUP => 1 );
 
@@ -43,7 +45,7 @@ script/testapp_test.pl
 script/testapp_create.pl
 |;
 
-plan 'tests' => scalar @files + 3;
+plan 'tests' => scalar @files + 4;
 
 foreach my $fn (@files) {
     ok -r $fn, "Have $fn in generated app";
@@ -57,3 +59,22 @@ my $newapp_test_status = `prove -l t/`;
 ok $newapp_test_status, "Tests ran okay";
 #is $newapp_test_status, ;
 
+## Moosey server tests - kmx++
+my $server_path   = File::Spec->catfile('script', 'testapp_server.pl');
+my $childpid = fork();
+
+my $port = 3333; # or call some random generator
+my $tmpfile = tmpnam(); # do not redirect to /dev/null as it will not work on Win32
+
+if ($childpid == 0) {
+  system("$^X $server_path -p $port > $tmpfile 2>&1");
+  exit;
+}
+
+sleep 10; #wait for catalyst application to start
+my $mech = Test::WWW::Mechanize->new;
+$mech->get_ok( "http://localhost:" . $port );
+
+kill 'KILL', $childpid;
+unlink $tmpfile;
+