Added Test::WWW::Mechanize::Catalyst support
Sebastian Riedel [Fri, 3 Mar 2006 15:57:55 +0000 (15:57 +0000)]
Changes
Makefile.PL
lib/Catalyst/Helper.pm

diff --git a/Changes b/Changes
index 7aa8a51..a4c29d2 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 This file documents the revision history for Perl extension Catalyst.
 
 5.66
+        - Added Test::WWW::Mechanize::Catalyst support
         - Cleaned generated tests
        - Change redirect to use a 301, not a 302
         - Added Root controller concept
index c978eed..abe6b09 100644 (file)
@@ -36,7 +36,7 @@ requires 'File::Copy::Recursive';
 requires 'Module::Install::Admin' => '0.54';
 requires 'Module::Install'        => '0.54';
 requires 'YAML'                   => '0.55';
-requires 'Data::Visitor'                 => '0.02';
+requires 'Data::Visitor'          => '0.02';
 
 feature 'Apache/mod_perl Support',
   -default                   => 0,
@@ -44,6 +44,10 @@ feature 'Apache/mod_perl Support',
 
 feature 'FastCGI Support', -default => 0, 'FCGI' => 0, 'FCGI::ProcManager' => 0;
 
+feature 'Test::WWW::Mechanize::Catalyst Support',
+  -default                         => 0,
+  'Test::WWW::Mechanize::Catalyst' => 0;
+
 feature 'PAR Support',
   -default => 0,
   'PAR'    => 0;
index acc818b..74fe38c 100644 (file)
@@ -992,16 +992,18 @@ use Pod::Usage;
 use Catalyst::Helper;
 
 my $force = 0;
+my $mech  = 0;
 my $help  = 0;
 
 GetOptions(
-    'nonew|force' => \$force,
-    'help|?'      => \$help
+    'nonew|force'    => \$force,
+    'mech|mechanize' => \$mech,
+    'help|?'         => \$help
  );
 
 pod2usage(1) if ( $help || !$ARGV[0] );
 
-my $helper = Catalyst::Helper->new( { '.newfiles' => !$force } );
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
 
 pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
 
@@ -1016,11 +1018,13 @@ pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
 [% appprefix %]_create.pl [options] model|view|controller name [helper] [options]
 
  Options:
-   -force    don't create a .new file where a file to be created exists
-   -help     display this help and exits
+   -force        don't create a .new file where a file to be created exists
+   -mechanize    use Test::WWW::Mechanize::Catalyst for tests if available
+   -help         display this help and exits
 
  Examples:
    [% appprefix %]_create.pl controller My::Controller
+   [% appprefix %]_create.pl -mechanize controller My::Controller
    [% appprefix %]_create.pl view My::View
    [% appprefix %]_create.pl view MyView TT
    [% appprefix %]_create.pl view TT TT
@@ -1105,12 +1109,24 @@ it under the same terms as Perl itself.
 __comptest__
 use strict;
 use warnings;
-[% IF long_type == 'Controller' %]use Test::More tests => 3;
+[% IF long_type == 'Controller' %][% IF mech %]our $test_count;
+use Test::More;
+
+eval "use Test::WWW::Mechanize::Catalyst '[% app %]'";
+plan $@
+    ? ( skip_all => 'Test::WWW::Mechanize::Catalyst required' )
+    : ( tests => 2 );
+
+ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' );
+
+$mech->get_ok( 'http://localhost[% uri %]' );
+[% ELSE %]use Test::More tests => 3;
 
 BEGIN { use_ok 'Catalyst::Test', '[% app %]' }
 BEGIN { use_ok '[% class %]' }
 
 ok( request('[% uri %]')->is_success, 'Request should succeed' );
+[% END %]
 [% ELSE %]use Test::More tests => 1;
 
 BEGIN { use_ok '[% class %]' }