Not so much use_ok
Tomas Doran [Tue, 11 Jan 2011 23:45:16 +0000 (23:45 +0000)]
Changes
share/t/01app.t.tt
share/t/comptest.tt

diff --git a/Changes b/Changes
index bd56ac6..711d074 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 This file documents the revision history for Perl extension Catalyst-Devel.
 
+        - Don't bother with the BEGIN { use_ok dance for created tests
+          - the test will fail to compile (and ergo fail) using just use,
+          and that's less typing (and less copy-pasting)
         - Split method for creating tests into multiple methods to allow
           subclasses to override the generation of some tests.
         - Allow the author to be defined in the call to ->new to help things
index d0f43dd..71d9f67 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 use Test::More;
 
-BEGIN { use_ok 'Catalyst::Test', '[% name %]' }
+use Catalyst::Test '[% name %]';
 
 ok( request('/')->is_success, 'Request should succeed' );
 
index 1e38a12..ff5420c 100644 (file)
@@ -1,9 +1,9 @@
 use strict;
 use warnings;
-[% IF long_type == 'Controller' %][% IF mech %]use Test::More;
+use Test::More;
+[% IF long_type == 'Controller' %][% IF mech %]
 
-eval "use Test::WWW::Mechanize::Catalyst '[% name %]'";
-if ($@) {
+unless (eval q{use Test::WWW::Mechanize::Catalyst '[% name %]'; 1}) {
     plan skip_all => 'Test::WWW::Mechanize::Catalyst required';
     exit 0;
 }
@@ -11,10 +11,10 @@ if ($@) {
 ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' );
 
 $mech->get_ok( 'http://localhost[% uri %]' );
-[%- ELSE %]use Test::More;
+[%- ELSE %]
 
-BEGIN { use_ok 'Catalyst::Test', '[% app %]' }
-BEGIN { use_ok '[% class %]' }
+use Catalyst::Test '[% app %]';
+use [% class %];
 
 ok( request('[% uri %]')->is_success, 'Request should succeed' );
 [%- END -%]