diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-08-11 09:59:29 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-08-11 09:59:29 +0200 |
| commit | afb209cbcfae7b88d8fb23ed04c47e1aee187b2a (patch) | |
| tree | 6b113aedc62a3ad0548a157d74054ec096720ddd /t/05_override_validate_implementation.t | |
| download | moosex-abstractfactory-afb209cbcfae7b88d8fb23ed04c47e1aee187b2a.tar.gz | |
initial commit
Diffstat (limited to '')
| -rw-r--r-- | t/05_override_validate_implementation.t | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/05_override_validate_implementation.t b/t/05_override_validate_implementation.t new file mode 100644 index 0000000..652f063 --- /dev/null +++ b/t/05_override_validate_implementation.t @@ -0,0 +1,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";
\ No newline at end of file |
