summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/MooseX/AbstractFactory/Role.pm2
-rw-r--r--t/06_die_with_inexistant_class.t18
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/MooseX/AbstractFactory/Role.pm b/lib/MooseX/AbstractFactory/Role.pm
index d560ca9..3b27f60 100644
--- a/lib/MooseX/AbstractFactory/Role.pm
+++ b/lib/MooseX/AbstractFactory/Role.pm
@@ -22,7 +22,7 @@ sub create {
         # pull in our implementation class
         $factory->_validate_implementation_class($iclass);
 
-        eval "use $iclass";
+        Class::MOP::load_class($iclass);
 
         my $options = $factory->_options();
 
diff --git a/t/06_die_with_inexistant_class.t b/t/06_die_with_inexistant_class.t
new file mode 100644
index 0000000..fcf600b
--- /dev/null
+++ b/t/06_die_with_inexistant_class.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+use Test::Exception;
+
+BEGIN {
+	package My::Factory;
+	use MooseX::AbstractFactory;
+	use Moose;
+}
+
+dies_ok {
+	my $imp = My::Factory->create(
+    	'FooBar', {}
+	);
+} "Factory->new() die";
+
+like $@, qr/Can't locate My\/Factory\/FooBar.pm/;