summaryrefslogtreecommitdiffstats
path: root/t/002-add-traits.t
blob: f3bb92c88052ade7132ee0e9ead5151cf0ae8a98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 4;
use Test::Moose;

BEGIN {
    package Foo::Exporter;
    use MooseX::MethodTraits;

    MooseX::MethodTraits->setup_import_methods(
        with_traits => {
            command => {
                traits => ['Foo::Command'],
            },
            other => {
                traits => ['Foo::OtherTrait'],
            },
        },
    );
}

{
    package Foo::Command;
    use Moose::Role;
}

{
    package Foo::OtherTrait;
    use Moose::Role;
}

{
    package Foo;
    use Moose;
    BEGIN { Foo::Exporter->import }

    command foo => sub { 'FOO' };
    other 'foo';
}

my $foo = Foo->new;
can_ok($foo, 'foo');
my $method = Foo->meta->get_method('foo');
does_ok($method, 'Foo::Command');
does_ok($method, 'Foo::OtherTrait');
is($foo->foo, 'FOO', 'correct method is installed');