role support, in MooseX::StrictConstructor::FromRole
[gitmo/MooseX-StrictConstructor.git] / t / role.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Fatal;
6 use Test::Moose qw( with_immutable );
7
8 {
9     package Role;
10
11     use Moose::Role;
12     use MooseX::StrictConstructor::FromRole;
13
14     has 'size' => ( is => 'rw' );
15 }
16
17 {
18     package Standard;
19
20     use Moose;
21     with 'Role';
22
23     has 'thing' => ( is => 'rw' );
24 }
25
26 my @classes = qw( Standard );
27 with_immutable {
28
29     like(
30         exception { Standard->new( thing => 1, bad => 99 ) },
31         qr/unknown attribute.+: bad/,
32         'strict constructor applied from role blows up on unknown params'
33     );
34 }
35 @classes;
36
37 done_testing();