Support is => 'bare' for compatibility
[gitmo/Mouse.git] / t / 501_moose_coerce_mouse.t
index dc8edde..2165482 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use Test::More;
 use Test::Exception;
 BEGIN {
-    plan skip_all => "Moose required for this test" unless eval { require Moose  && Moose->VERSION('0.59') };
+    plan skip_all => "Moose 0.68 required for this test" unless eval { require Moose  && Moose->VERSION('0.68') };
     plan tests => 5;
 }
 
@@ -20,14 +20,14 @@ use Test::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',
@@ -43,10 +43,14 @@ use Test::Exception;
 }
 
 {
+    local $TODO = "Doesn't work in the constructor yet?";
     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');
+}
+
+{
+    my $r = Mosponse->new;
     $r->headers({foo => 'yay'});
     isa_ok($r->headers, 'Headers');
     is($r->headers->foo, 'yay');