Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use 5.024;
- use Test::Most;
- package C {
- use Moo::Role;
- has dir => ( is => 'ro', required => 1 );
- has file => ( is => 'ro', default => sub { sprintf '%s/%s.pm.ep' => $_[0]->dir, ref($_[0]) =~ s/::/\//gr } );
- };
- package A {
- use Moo;
- with 'C';
- };
- package B {
- use Moo;
- with 'C';
- };
- package D::E {
- use Moo;
- with 'C';
- };
- subtest 'template_file is different per role' => sub {
- cmp_deeply(
- new_ok( A => [ dir => '/tmp' ] ),
- methods( file => '/tmp/A.pm.ep' ),
- 'get the correct template',
- );
- cmp_deeply(
- new_ok( B => [ dir => '/tmp' ] ),
- methods( file => '/tmp/B.pm.ep' ),
- 'get the correct template',
- );
- cmp_deeply(
- new_ok( 'D::E' => [ dir => '/tmp' ] ),
- methods( file => '/tmp/D/E.pm.ep' ),
- 'get the correct template',
- );
- };
- done_testing;
Add Comment
Please, Sign In to add comment