Created
June 15, 2010 10:59
-
-
Save j1n3l0/438975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Modern::Perl; | |
use Test::Most; | |
=head1 OVERVIEW | |
Moose will load a class specified via an attributes C<isa> option. | |
=cut | |
{ | |
package Foo; | |
use Moose; | |
has bar => ( | |
isa => 'REST::Client', | |
is => 'ro', | |
default => sub { REST::Client->new() }, | |
handles => ['GET'], | |
); | |
::dies_ok { Foo->new->GET($0) } | |
'does not automatically load REST::Client via isa'; | |
} | |
{ | |
package Bar; | |
use Moose; | |
extends 'Foo'; | |
has '+bar' => ( | |
default => sub { | |
require REST::Client; | |
REST::Client->new(); | |
}, | |
); | |
::lives_ok { Bar->new->GET($0) } | |
'now passes as REST::Client is explicitely required'; | |
} | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment