Test::Moose::MockObjectCompile - A Module to help when testing compile time Moose
use Test::Moose::MockObjectCompile; use Test::More; my $mock = Test::Moose::MockObjectCompile->new(); $mock->roles([qw{Some::Role Some::Other::Role}]); $mock->mock('method1'); lives_ok {$mock->compile} 'Test that roles don't clash and required methods are there';
a list of roles to apply to your package.
a list of Moose packages you want your package to extend
the constructor for a MockObjectCompile(r) it expects a hashref with the package key passed in to define the package name or it will throw an exception.
simulates a compile of the mocked Moose Object with the definition defined in your roles and extend attributes and whatever you told it to mock.
mocks a method in your compiled Mock Moose Object. It expects a name for the method and an optional coderef.
$mock->mock('method1', '{ push @stuff, $_[1];}');
Some things to keep in mind are:
this module actually compiles your package this means that any subsequent compiles only modify the package they don't replace it. If you want to make sure you don't have stuff haning around from previouse compiles change the package or make a new instance with a different package name. This way you can be sure you start out with a fresh module namespace.
Jeremy Wall <jeremy@marzhillstudios.com>
This program is free software you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.Perl.com/perl/misc/Artistic.html
To install Test::Moose::MockObjectCompile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Moose::MockObjectCompile
CPAN shell
perl -MCPAN -e shell install Test::Moose::MockObjectCompile
For more information on module installation, please visit the detailed CPAN module installation guide.