Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created September 10, 2012 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j1n3l0/3691109 to your computer and use it in GitHub Desktop.
Save j1n3l0/3691109 to your computer and use it in GitHub Desktop.
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment