New bare bones Mock module: Test::Mock::Simple

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I creating a new my new module Test::Mock::Simple which contains no helpers
 and all it does is replace a name space's method that you specify.

Sample code:
my $total = 0;
my $mock = Test::Mock::Simple->new(module => 'Original::Module');
$mock->it(add => sub { shift; return $total += shift; });
$mock->it(remove => sub { shift; return $total -= shift; });

my $obj = Original::Module->new();
print $obj->sum . "\n"; # prints 3

Of course this is a contrived example but it allows overriding Original::Mo
dule's add and remove method while letting other methods to still work corr

I realize there are several Mocking object, however, they all have a specif
ic purpose or attempt to help you out; thereby getting in the way (at least
 for my needs at the moment). I want to call is Test::Mock::Simple because  
it only provides 1 method which overrides a method in a name space with a n
ew subroutine.  

I appreciate your thoughts and feedback,

Erik Tank

Site Timeline