CatalystX::LeakChecker needs to be injected into the Context class now
Zbigniew Łukasiak [Tue, 17 Nov 2009 13:40:49 +0000 (13:40 +0000)]
t/lib/TestApp.pm
t/lib/TestApp/Context.pm [new file with mode: 0644]

index a2fc0b2..94bddd9 100644 (file)
@@ -12,6 +12,7 @@ use Catalyst qw/
     +TestApp::Role
 /;
 use Catalyst::Utils;
+use TestApp::Context;
 
 use Moose;
 use namespace::autoclean;
@@ -20,25 +21,7 @@ our $VERSION = '0.01';
 
 TestApp->config( name => 'TestApp', root => '/some/dir' );
 
-if (eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) {
-    with 'CatalystX::LeakChecker';
-
-    has leaks => (
-        is      => 'ro',
-        default => sub { [] },
-    );
-}
-
-sub found_leaks {
-    my ($ctx, @leaks) = @_;
-    push @{ $ctx->leaks }, @leaks;
-}
-
-sub count_leaks {
-    my ($ctx) = @_;
-    return scalar @{ $ctx->leaks };
-}
-
+TestApp->context_class( 'TestApp::Context' );
 TestApp->setup;
 
 sub execute {
diff --git a/t/lib/TestApp/Context.pm b/t/lib/TestApp/Context.pm
new file mode 100644 (file)
index 0000000..3b09d79
--- /dev/null
@@ -0,0 +1,25 @@
+package TestApp::Context;
+use Moose;
+extends 'Catalyst::Context'; 
+
+if (eval { Class::MOP::load_class('CatalystX::LeakChecker'); 1 }) {
+    with 'CatalystX::LeakChecker';
+
+    has leaks => (
+        is      => 'ro',
+        default => sub { [] },
+    );
+}
+
+sub found_leaks {
+    my ($ctx, @leaks) = @_;
+    push @{ $ctx->leaks }, @leaks;
+}
+
+sub count_leaks {
+    my ($ctx) = @_;
+    return scalar @{ $ctx->leaks };
+}
+
+1;
+