summaryrefslogtreecommitdiff
path: root/t/01_factory.t
blob: 7c49cb471045a7238b989efea9bff0d583c7b2e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use Test::More tests => 6;
use Test::Moose;
use Test::Exception;

BEGIN {
	package My::Factory::Implementation;
	use Moose;

	has connection => (is => 'ro', isa => 'Str');

	sub tweak { 1; };

	package My::Factory;
	use MooseX::AbstractFactory;
	use Moose;
}

my $imp;

lives_ok { 
	$imp = My::Factory->create(
    	'Implementation',
    	{ connection => 'Type1' }
	);
} "Factory->new() doesn't die";

isa_ok($imp, "My::Factory::Implementation");

can_ok($imp, qw/tweak/);
is($imp->tweak(),1,"tweak returns 1");
is($imp->connection(), 'Type1', 'connection attr set by constructor');

dies_ok {
	$imp->fudge();
} "fudge dies, not implemented on implementor";