#!/usr/bin/env perl
-
use strict;
use warnings;
-use Test::More tests => 4;
-my $app = { app => 'oh yeah' };
-
-my $foo = Foo->COMPONENT($app, { args => 'yes' });
-is $foo->{args}, 'yes', 'foo created';
-is $foo->context->{app}, 'oh yeah', 'got app';
+{
+ package MyApp;
+ use Moose;
+ use Catalyst;
+ no Moose;
-my $ctx = { ctx => 'it is' };
-my $foo2 = $foo->ACCEPT_CONTEXT($ctx);
-is $foo, $foo2, 'foo and foo2 are the same ref';
-is $foo->context->{ctx}, 'it is', 'got ctx';
+ sub _is_this_the_app { 'oh yeah' }
+}
{
package Foo;
my $class = shift;
return $class->next::method(@_);
}
-
}
+
+use Test::More tests => 4;
+use Scalar::Util qw/refaddr/;
+
+my $app_class = 'MyApp';
+
+my $foo = Foo->COMPONENT($app_class, { args => 'yes' });
+is $foo->{args}, 'yes', 'foo created';
+is $foo->context->_is_this_the_app, 'oh yeah', 'got app';
+
+my $ctx = { };
+my $foo2 = $foo->ACCEPT_CONTEXT($ctx);
+is refaddr($foo), refaddr($foo2), 'foo and foo2 are the same ref';
+is refaddr($foo->context), refaddr($ctx), 'got ctx';
+