From: Pedro Melo Date: Fri, 27 Nov 2009 17:50:42 +0000 (+0000) Subject: Moose::Exporter fails to apply metaclass_roles X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fabandoned%2Fm-exporter-metaclass_roles-bug;p=gitmo%2FMoose.git Moose::Exporter fails to apply metaclass_roles The generated code for init_meta (starts at line 504 of Moose::Exporter) will bail out at the top via: return unless Class::MOP::class_of( $options{for_class} ); This happends because at this time, there is no ->meta() for the $options{for_class}. --- diff --git a/t/050_metaclasses/012_moose_exporter.t b/t/050_metaclasses/012_moose_exporter.t index 93ec1bb..6efa2e9 100644 --- a/t/050_metaclasses/012_moose_exporter.t +++ b/t/050_metaclasses/012_moose_exporter.t @@ -8,7 +8,7 @@ use Test::Exception; BEGIN { eval "use Test::Output;"; plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 65; + plan tests => 68; } @@ -389,3 +389,33 @@ BEGIN { ok( ! UseAllOptions->can($_), "UseAllOptions::$_ has been unimported" ) for qw( with_meta1 with_meta2 with_caller1 with_caller2 as_is1 ); } + +{ + package MyTraitWithAttr; + use Moose::Role; + + has 'registry' => ( is => 'ro' ); +} + +{ + package MyMooseExporterForAttr; + use Moose (); + use Moose::Exporter; + + Moose::Exporter->setup_import_methods( + metaclass_roles => ['MyTraitWithAttr'], + also => 'Moose', + ); +} + +{ + package MyAttrTraitUser; + MyMooseExporterForAttr->import(); +} + +{ + ok(MyMooseExporterForAttr->can('meta'), 'MyAttrTraitUser has meta()'); + my $meta; + lives_ok sub { MyMooseExporterForAttr->meta}, '... and we can call it'; + ok($meta->can('registry'), '... and our MyTraitWithAttr was applied'); +}