X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F501_moose_coerce_mouse.t;h=ce7ee0cfd8f40f5f3b26e368168fb1f8ad48c4ce;hb=09584bc5021e29580b6f86ac8b81375d0e84e55a;hp=68c420f8fd6538e0735fb52fefe4d49d2943e034;hpb=3c40a22570a1412a4c442f5c64a56d8c5a7e688c;p=gitmo%2FMouse.git diff --git a/t/501_moose_coerce_mouse.t b/t/501_moose_coerce_mouse.t index 68c420f..ce7ee0c 100644 --- a/t/501_moose_coerce_mouse.t +++ b/t/501_moose_coerce_mouse.t @@ -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');