public

  • Download Gist
2012-09-10_before_a_bunch_of_methods.t
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use 5.014;
use Test::Most;
 
{
package Foo;
use Moose;
has foo => qw( is ro );
sub bar { "made it to bar" }
sub baz { "made it to bar" }
before [qw(bar baz)] => sub { die "no foo" unless shift->foo }
}
 
note "foo is undefined";
{
my $foo = new_ok Foo => [];
dies_ok { $foo->bar } "\$foo->bar dies";
dies_ok { $foo->baz } "\$foo->baz dies";
}
 
note "foo is defined";
{
my $foo = new_ok Foo => [ foo => 1 ];
lives_ok { $foo->bar } "\$foo->bar lives";
lives_ok { $foo->baz } "\$foo->baz lives";
}
 
done_testing;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.