summaryrefslogtreecommitdiff
path: root/t/05_override_validate_implementation.t
blob: 652f063203f265c1e28cff6d3aad36d77c13be7d (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
36
37
38
39
40
41
42
43
44
45
46
47
use Test::More tests => 2;
use Test::Exception;

BEGIN {
	#----------------------------------------------------
    package My::Implementation;
    use Moose;

	#----------------------------------------------------
	# Factory class, all implementations valid
    package My::FactoryA;
    use MooseX::AbstractFactory;

	implementation_class_via sub { "My::Implementation" };

	sub _validate_implementation_class {
		return;
	}

	#----------------------------------------------------
	# Factory class, all implementations invalid
    package My::FactoryB;
    use MooseX::AbstractFactory;

	implementation_class_via sub { "My::Implementation" };

	sub _validate_implementation_class {
		confess "invalid implementation";
	}

}

my $imp;

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

dies_ok {
    $imp = My::FactoryB->create(
                               'Implementation',
                               {},
                              );
}
"FactoryB->new() dies with implementation";