class_type shouldn't load the class (Moose compat; no easy fix :/)
[gitmo/Mouse.git] / t / 800_shikabased / 005-class_type.t
1 use strict;
2 use warnings;
3 use Test::More tests => 4;
4 {
5     package Response;
6     use Mouse;
7     use Mouse::Util::TypeConstraints;
8
9     require t::lib::ClassType_Foo;
10
11     class_type Headers => { class => 't::lib::ClassType_Foo' };
12     coerce 'Headers' =>
13         from 'HashRef' => via {
14             t::lib::ClassType_Foo->new(%{ $_ });
15         },
16     ;
17
18     has headers => (
19         is     => 'rw',
20         isa    => 'Headers',
21         coerce => 1,
22     );
23 }
24
25 my $res = Response->new(headers => { foo => 'bar' });
26 isa_ok($res->headers, 't::lib::ClassType_Foo');
27 is($res->headers->foo, 'bar');
28 $res->headers({foo => 'yay'});
29 isa_ok($res->headers, 't::lib::ClassType_Foo');
30 is($res->headers->foo, 'yay');