Make test skips actually work, fixes RT#47037
Tomas Doran [Mon, 8 Mar 2010 01:19:03 +0000 (01:19 +0000)]
t/cookies.t
t/two_app.t

index 823adb6..3017d36 100644 (file)
@@ -4,20 +4,23 @@ use warnings;
 use lib 'lib';
 use Test::More;
 
-eval {
-    require Catalyst::Plugin::Session;
-    require Catalyst::Plugin::Session::State::Cookie;
-};
+BEGIN {
+    eval {
+        require Catalyst::Plugin::Session;
+        require Catalyst::Plugin::Session::State::Cookie;
+    };
 
-if ($@) {
-    diag($@);
-    plan skip_all => "Need Catalyst::Plugin::Session to run this test";
-} else {
-    plan tests => 3;
+    if ($@) {
+        diag($@);
+        plan skip_all => "Need Catalyst::Plugin::Session to run this test";
+        exit 0;
+    }
 }
 use lib 't/lib';
 use Test::WWW::Mechanize::Catalyst 'CattySession';
 
+plan tests => 3;
+
 my $m = Test::WWW::Mechanize::Catalyst->new;
 $m->credentials( 'user', 'pass' );
 
index a54529b..edbcc27 100644 (file)
@@ -4,20 +4,23 @@ use warnings;
 use Test::More;
 use lib 't/lib';
 
-eval {
-    require Catalyst::Plugin::Session;
-    require Catalyst::Plugin::Session::State::Cookie;
-};
-
-if ($@) {
-    diag($@);
-    plan skip_all => "Need Catalyst::Plugin::Session to run this test";
-} else {
-    plan tests => 4;
+BEGIN {
+    eval {
+        require Catalyst::Plugin::Session;
+        require Catalyst::Plugin::Session::State::Cookie;
+    };
+
+    if ($@) {
+        diag($@);
+        plan skip_all => "Need Catalyst::Plugin::Session to run this test";
+        exit 0;
+    }
 }
 
 use Test::WWW::Mechanize::Catalyst;
 
+plan tests => 4;
+
 my $m1 = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'Catty');
 my $m2 = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'CattySession');