summaryrefslogtreecommitdiff
path: root/t/01_factory.t
diff options
context:
space:
mode:
Diffstat (limited to 't/01_factory.t')
-rw-r--r--t/01_factory.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/01_factory.t b/t/01_factory.t
new file mode 100644
index 0000000..7c49cb4
--- /dev/null
+++ b/t/01_factory.t
@@ -0,0 +1,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"; \ No newline at end of file