Real attribute objects in roles is now working, with a few hacks and changes to the...
[gitmo/Moose.git] / t / 030_roles / 001_meta_role.t
index f8b377b..bc86e1a 100644 (file)
@@ -3,16 +3,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 27;
+use Test::More;
 use Test::Exception;
 
 use Moose::Meta::Role;
 
 {
     package FooRole;
-    
+
     our $VERSION = '0.01';
-    
+
     sub foo { 'FooRole::foo' }
 }
 
@@ -34,7 +34,7 @@ is_deeply(
     [ $foo_role->get_method_list() ],
     [ 'foo' ],
     '... got the right method list');
-    
+
 # attributes ...
 
 is_deeply(
@@ -55,10 +55,14 @@ is_deeply(
 
 ok($foo_role->has_attribute('bar'), '... FooRole does have the bar attribute');
 
-is_deeply(
-    $foo_role->get_attribute('bar'),
-    { is => 'rw', isa => 'Foo' },
-    '... got the correct description of the bar attribute');
+my $bar = $foo_role->get_attribute('bar');
+is( $bar->get_read_method, 'bar', 'bar has a reader named bar' );
+is( $bar->get_write_method, 'bar', 'bar has a writer named bar' );
+is(
+    $bar->type_constraint,
+    Moose::Util::TypeConstraints::class_type('Foo'),
+    'bar has a Foo class type'
+);
 
 lives_ok {
     $foo_role->add_attribute('baz' => (is => 'ro'));
@@ -71,10 +75,9 @@ is_deeply(
 
 ok($foo_role->has_attribute('baz'), '... FooRole does have the baz attribute');
 
-is_deeply(
-    $foo_role->get_attribute('baz'),
-    { is => 'ro' },
-    '... got the correct description of the baz attribute');
+my $baz = $foo_role->get_attribute('baz');
+is( $baz->get_read_method, 'baz', 'baz has a reader named baz' );
+is( $baz->get_write_method, undef, 'baz does not have a writer' );
 
 lives_ok {
     $foo_role->remove_attribute('bar');
@@ -104,3 +107,5 @@ is_deeply(
     [ $foo_role->get_method_modifier_list('before') ],
     [ 'boo' ],
     '... got the right list of before method modifiers');
+
+done_testing;