From: Tomas Doran Date: Tue, 11 Jan 2011 23:45:16 +0000 (+0000) Subject: Not so much use_ok X-Git-Tag: 1.29~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Devel.git;a=commitdiff_plain;h=7413e76d3ddf736ebbb986f914e6237cfd15ec84 Not so much use_ok --- diff --git a/Changes b/Changes index bd56ac6..711d074 100644 --- 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 diff --git a/share/t/01app.t.tt b/share/t/01app.t.tt index d0f43dd..71d9f67 100644 --- a/share/t/01app.t.tt +++ b/share/t/01app.t.tt @@ -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' ); diff --git a/share/t/comptest.tt b/share/t/comptest.tt index 1e38a12..ff5420c 100644 --- a/share/t/comptest.tt +++ b/share/t/comptest.tt @@ -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 -%]