On Thu, Oct 25, 2012 at 04:05:05PM +0100, David Cantrell wrote:
> I'm liberating some code that we use at work.  A first cut at CPAN-
> ising it is here (yes, I know it has no tests yet):
>   https://github.com/DrHyde/perl-Devel-Mockable
> 
> What do people think?  The aim is to:

I just took a quick glance while I had a minute, so this isn't very
in-depth:

- our::way: is that a local pragma? it isn't on cpan.
- instead of manually writing into the symbol table, use one of the export
  modules: Exporter, Sub::Exporter, Exporter::Declare etc.
- I'm not sure if this belongs in the Devel namespace - someone else with
  better knowledge of the nomenclature would be better able to say.

How does this add value above simply storing a class name in an accessor
(e.g. a Class::Accessor field or Moose attribute)?  In moose, I could do
this:

has useragent => ( is => 'ro', isa => 'Str', default => 'LWP::UserAgent' );

and then in testing, simply construct my class as:
my $obj = Foo->new(..., useragent => 'Test::LWP::UserAgent');
...to swap out its implementation with something that is mockable.


-- 
             Don't anthromoporphize computers.  They _hate_ that!
            .             .            .            .             .
Karen Etheridge, ka...@etheridge.ca       GCS C+++$ USL+++$ P+++$ w--- M++

Reply via email to