4 use Test::More tests => 2;
8 # Not in the recipe, but needed for writing tests.
22 predicate => 'has_work',
27 package MyApp::Role::Job::Manager;
29 use List::Util qw( first );
35 isa => 'ArrayRef[Employee]',
42 my $employee = first { !$_->has_work } @{ $self->employees };
44 die 'All my employees have work to do!' unless $employee;
46 $employee->work($work);
51 my $lisa = Employee->new( name => 'Lisa' );
52 MyApp::Role::Job::Manager->meta->apply($lisa);
54 ok( $lisa->does('MyApp::Role::Job::Manager'),
55 'lisa now does the manager role' );
57 my $homer = Employee->new( name => 'Homer' );
58 my $bart = Employee->new( name => 'Bart' );
59 my $marge = Employee->new( name => 'Marge' );
61 $lisa->employees( [ $homer, $bart, $marge ] );
62 $lisa->assign_work('mow the lawn');
64 is( $homer->work, 'mow the lawn',
65 'homer was assigned a task by lisa' );