From: Jesse Luehrs Date: Sun, 19 Jun 2011 06:52:07 +0000 (-0500) Subject: tests and changelog X-Git-Tag: 2.0103~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=360e6512dc9e37492c765ed77ceaa69d46572a8d;p=gitmo%2FMoose.git tests and changelog --- diff --git a/Changes b/Changes index 2b67c73..e06095d 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,11 @@ for, noteworthy changes. * Moose::Util::apply_all_roles now works even if the applicant is a non-Moose class. (perigrin) + [OTHER] + + * Better error message if Moose->init_meta is called with a 'metaclass' + option when that metaclass hasn't been loaded. (jasonmay) + 2.0102 Sat, Jun 18, 2011 [ENHANCEMENTS] diff --git a/t/metaclasses/moose_exporter.t b/t/metaclasses/moose_exporter.t index 3635a8b..66a0f30 100644 --- a/t/metaclasses/moose_exporter.t +++ b/t/metaclasses/moose_exporter.t @@ -416,4 +416,46 @@ use Test::Requires { for qw( with_meta1 with_meta2 with_caller1 with_caller2 as_is1 ); } +{ + package InitMetaError; + use Moose::Exporter; + use Moose (); + Moose::Exporter->setup_import_methods(also => ['Moose']); + sub init_meta { + my $package = shift; + my %options = @_; + Moose->init_meta(%options, metaclass => 'Not::Loaded'); + } +} + +{ + package InitMetaError::Role; + use Moose::Exporter; + use Moose::Role (); + Moose::Exporter->setup_import_methods(also => ['Moose::Role']); + sub init_meta { + my $package = shift; + my %options = @_; + Moose::Role->init_meta(%options, metaclass => 'Not::Loaded'); + } +} + +{ + package WantsInvalidMetaclass; + ::like( + ::exception { InitMetaError->import }, + qr/The Metaclass Not::Loaded must be loaded\. \(Perhaps you forgot to 'use Not::Loaded'\?\)/, + "error when wanting a nonexistent metaclass" + ); +} + +{ + package WantsInvalidMetaclass::Role; + ::like( + ::exception { InitMetaError::Role->import }, + qr/The Metaclass Not::Loaded must be loaded\. \(Perhaps you forgot to 'use Not::Loaded'\?\)/, + "error when wanting a nonexistent metaclass" + ); +} + done_testing;