t/001_basic.t - add ro test
[gitmo/Moose-Policy.git] / t / 001_basic.t
index 867445b..fced719 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 8;
+use Test::More 'no_plan';
 
 BEGIN {
     use_ok('Moose::Policy');           
@@ -15,6 +15,8 @@ BEGIN {
     
     extends 'Moose::Meta::Attribute';
     
+    # this method (mostly stolen from M::M::Attribute) just rebuilds the
+    # options so anything with 'is' gets PBP accessors
     sub _process_options {
         my ($class, $name, $options) = @_;
        if (exists $options->{is}) {
@@ -34,6 +36,7 @@ BEGIN {
 
 {
     package My::Moose::Policy;
+    # policy just specifies metaclass delegates
     use constant attribute_metaclass => 'My::Moose::Meta::Attribute';
 }
 
@@ -44,6 +47,7 @@ BEGIN {
     use Moose;
     
     has 'bar' => (is => 'rw', default => 'Foo::bar');
+    has 'baz' => (is => 'ro', default => 'Foo::baz');
 }
 
 isa_ok(Foo->meta, 'Moose::Meta::Class');
@@ -57,7 +61,10 @@ isa_ok($foo, 'Foo');
 can_ok($foo, 'get_bar');
 can_ok($foo, 'set_bar');
 
+can_ok($foo, 'get_baz');
+
 is($foo->get_bar, 'Foo::bar', '... got the right default value');
+is($foo->get_baz, 'Foo::baz', '... got the right default value');