New modules
[gitmo/Moose.git] / t / 040_meta_role.t
index 205b0df..c13b336 100644 (file)
@@ -3,10 +3,11 @@
 use strict;
 use warnings;
 
-use Test::More tests => 27;
+use Test::More tests => 29;
 use Test::Exception;
 
 BEGIN {  
+    use_ok('Moose'); 
     use_ok('Moose::Meta::Role');               
 }
 
@@ -18,12 +19,9 @@ BEGIN {
     sub foo { 'FooRole::foo' }
 }
 
-my $foo_role = Moose::Meta::Role->new(
-    role_name => 'FooRole'
-);
+my $foo_role = Moose::Meta::Role->initialize('FooRole');
 isa_ok($foo_role, 'Moose::Meta::Role');
-
-isa_ok($foo_role->role_meta, 'Class::MOP::Class');
+isa_ok($foo_role, 'Class::MOP::Module');
 
 is($foo_role->name, 'FooRole', '... got the right name of FooRole');
 is($foo_role->version, '0.01', '... got the right version of FooRole');
@@ -31,7 +29,9 @@ is($foo_role->version, '0.01', '... got the right version of FooRole');
 # methods ...
 
 ok($foo_role->has_method('foo'), '... FooRole has the foo method');
-is($foo_role->get_method('foo'), \&FooRole::foo, '... FooRole got the foo method');
+is($foo_role->get_method('foo')->body, \&FooRole::foo, '... FooRole got the foo method');
+
+isa_ok($foo_role->get_method('foo'), 'Moose::Meta::Role::Method');
 
 is_deeply(
     [ $foo_role->get_method_list() ],
@@ -93,17 +93,15 @@ ok($foo_role->has_attribute('baz'), '... FooRole does still have the baz attribu
 
 # method modifiers
 
-ok(!$foo_role->has_method_modifier('before' => 'boo'), '... no boo:before modifier');
+ok(!$foo_role->has_before_method_modifiers('boo'), '... no boo:before modifier');
 
 my $method = sub { "FooRole::boo:before" };
 lives_ok {
-    $foo_role->add_method_modifier('before' => (
-        'boo' => $method
-    ));
+    $foo_role->add_before_method_modifier('boo' => $method);
 } '... added a method modifier okay';
 
-ok($foo_role->has_method_modifier('before' => 'boo'), '... now we have a boo:before modifier');
-is($foo_role->get_method_modifier('before' => 'boo'), $method, '... got the right method back');
+ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier');
+is(($foo_role->get_before_method_modifiers('boo'))[0], $method, '... got the right method back');
 
 is_deeply(
     [ $foo_role->get_method_modifier_list('before') ],