chromatic wrote: > On Thursday 05 October 2006 12:25, Christopher H. Laco wrote: > >> I'm having a idiot moment... >> >> I'm trying to mock out some config reading tests for reading from >> MP1/MP2 even though I don't have either installed. so I thought >> "Test::MockObjext is the answer!". >> >> The following code goes boom with a 'Can't locate object method request >> >> via package "Apache"': >>> use strict; >>> use warnings; >>> use Test::MockObject; >>> >>> my $mock = Test::MockObject->new; >>> $mock->fake_module('Apache'); >>> $mock->set_series(undef, $mockrequest); >>> >>> warn Apache->request; >> If I change the fake_module call to >> Test::MockObject->fake_module('Apache'), the code gets happt, but it >> appears I can then install subs into that Apache using any of the set_ >> helpers. >> >> Or am I just missing something? >> >> The pod mentions that fake_module is a class and object method, but >> doesn't really extol the virtues on when to use one over the other. > >> Someone cluestick me please. > > Test::MockObject primarily returns you an object on which you can mock and > call mocked methods. fake_module() lets you install new methods into the > mocked class by passing name and subref pairs, but that's really not the > point of the module. > > -- c > >
How is above any different than this: s/GEO::IP/Apache/ ? http://www.perl.com/pub/a/2005/04/07/mockobject_kata.html?page=2 Obviously, my brain is not working right today.
signature.asc
Description: OpenPGP digital signature