4 use Test::More 'no_plan';
10 # =begin testing SETUP
12 # Not in the recipe, but needed for writing tests.
26 predicate => 'has_work',
32 # =begin testing SETUP
35 package MyApp::Role::Job::Manager;
37 use List::Util qw( first );
43 isa => 'ArrayRef[Employee]',
50 my $employee = first { !$_->has_work } @{ $self->employees };
52 die 'All my employees have work to do!' unless $employee;
54 $employee->work($work);
59 my $lisa = Employee->new( name => 'Lisa' );
60 MyApp::Role::Job::Manager->meta->apply($lisa);
62 my $homer = Employee->new( name => 'Homer' );
63 my $bart = Employee->new( name => 'Bart' );
64 my $marge = Employee->new( name => 'Marge' );
66 $lisa->employees( [ $homer, $bart, $marge ] );
67 $lisa->assign_work('mow the lawn');
75 my $lisa = Employee->new( name => 'Lisa' );
76 MyApp::Role::Job::Manager->meta->apply($lisa);
78 my $homer = Employee->new( name => 'Homer' );
79 my $bart = Employee->new( name => 'Bart' );
80 my $marge = Employee->new( name => 'Marge' );
82 $lisa->employees( [ $homer, $bart, $marge ] );
83 $lisa->assign_work('mow the lawn');
85 ok( $lisa->does('MyApp::Role::Job::Manager'),
86 'lisa now does the manager role' );
88 is( $homer->work, 'mow the lawn',
89 'homer was assigned a task by lisa' );