diff options
Diffstat (limited to 't/002-add-traits.t')
-rw-r--r-- | t/002-add-traits.t | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/002-add-traits.t b/t/002-add-traits.t new file mode 100644 index 0000000..f3bb92c --- /dev/null +++ b/t/002-add-traits.t @@ -0,0 +1,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'); |