September 2013 Archives

Building your own Moose

So you've switched to Moose a long time ago and you're quite happy with it, but you slowly notice that there are, well, things you wish it did differently. Fortunately, there's the MooseX:: namespace and now you have boilerplate you type at the beginning of every module.

use Moose;
use MooseX::StrictConstructor;
use MooseX::HasDefaults::RO;
use My::Moose::Types;

The above incantation says "die if there are unknown arguments to new(), and attributes should be read-only by default, and throw in my custom-defined Moose types as well".

But boilerplate is bad. In my quest to remove boilerplate, I've produced Test::Most and other modules, but in this case, there's not much to release because many people's Moose preferences will be different. Still, it would be much nicer to write use My::Moose; rather than continually repeating the lines above, so here's how to do that.

Using git-bisect to track down warnings in your test suite

You've all seen this before:

$ prove -l t/some/test.t
t/some/test.t .. 51/? Use of uninitialized value $foobar in ...
t/some/test.t .. ok

Inspecting the code doesn't necessarily make it clear what the correct fix is, so you want to kick it back to the person who generated the warning. But that's not actually a test failure, so git-bisect doesn't work out of the box.

Test::Class::Moose introductory video

The video of my Test::Class::Moose presentation in Kiev is on Youtube. Follow that link, or watch this embedded version:

Note that the first two minutes is me waiting for everyone to arrive.

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/