(Re-)organize Method Accessor, implementing has ... reader => $r, accessor => $a...
[gitmo/Mouse.git] / t / 501_moose_coerce_mouse.t
index 68c420f..ce7ee0c 100644 (file)
@@ -4,13 +4,14 @@ use strict;
 use warnings;
 
 use Test::More;
-use t::Exception;
+use Test::Exception;
 BEGIN {
-    plan skip_all => "Moose required for this test" unless eval { require Moose  && Moose->VERSION('0.59') };
+    my $require_version = 0.68;
+    plan skip_all => "Moose $require_version required for this test" unless eval { require Moose  && Moose->VERSION($require_version) };
     plan tests => 5;
 }
 
-use t::Exception;
+use Test::Exception;
 
 {
     package Headers;
@@ -20,14 +21,14 @@ use t::Exception;
 {
     package Response;
     use Mouse;
-    use Mouse::TypeRegistry;
+    use Mouse::Util::TypeConstraints;
 
-    subtype 'HeadersType' => sub { defined $_ && eval { $_->isa('Headers') } };
-    coerce 'HeadersType' => +{
-        HashRef => sub {
+    type 'HeadersType' => where { defined $_ && eval { $_->isa('Headers') } };
+    coerce  'HeadersType' =>
+        from 'HashRef' => via {
             Headers->new(%{ $_ });
         },
-    };
+    ;
 
     has headers => (
         is     => 'rw',
@@ -44,9 +45,14 @@ use t::Exception;
 
 {
     my $r = Mosponse->new(headers => { foo => 'bar' });
-    local our $TODO = "Moose not yet aware of Mouse meta";
     isa_ok($r->headers, 'Headers');
-    is(eval{$r->headers->foo}, 'bar');
+    lives_and {
+        is $r->headers->foo, 'bar';
+    };
+}
+
+{
+    my $r = Mosponse->new;
     $r->headers({foo => 'yay'});
     isa_ok($r->headers, 'Headers');
     is($r->headers->foo, 'yay');