Re: use mocked

2007-02-23 Thread Ovid
--- Luke Closs <[EMAIL PROTECTED]> wrote:

> On 2/22/07, Ovid <[EMAIL PROTECTED]> wrote:
> >
> > Telling me "you can only use t/lib for mocked modules"
> 
> 
> Woah, dude.  mocked.pm loads mocked modules from t/lib.  You can use
> t/lib
> for whatever else you want.
> 
> So you could keep your existing test modules there, and put the mock
> test
> modules there too.

OK, I take your point.  I just have a personal preference for using
separate paths for separate types of modules.  So right now, if I see
something in t/lib/, I know that it's a helper module for tests.  I
would be tempted, were I creating multiple mocked modules, to create a
t/mocked/ directory, since I think code organization gets very
important as a codebase grows larger.

Still, t/lib doesn't seem like too bad of an idea :)

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/


Re: use mocked

2007-02-23 Thread Dominique Quatravaux
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Luke Closs wrote:
>
> use lib 't/lib'; use LWP::Simple; # this is a mocked library [...]
> use mocked 'LWP::Simple';

And, uh, how about this:

use lib 't';
use mock::LWP::Simple;

with the following directory layout:

t
  lib
Test
  Exception.pm
  mock
LWP
  Simple.pm

or something?

- --
<< Tout n'y est pas parfait, mais on y honore certainement les
jardiniers >>

Dominique Quatravaux <[EMAIL PROTECTED]>
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBRd7Cw/TYH7KfeIIFAQLfxQP+MhLUcsILjPCaI/w/6WkBEaT4azUJAO3l
gR74Dl1UkYX528qbsazxkZ6644ZN5EOxhoRfxcjf3YLcCz9nFiixxSErAn2W8vdI
PxWr71oo4NWWpGqvUq2eTpnEuMETVgZLsUQdAQRiWlA4hq9mv9nuh4IwnpxaSZSR
AyF92MRhhpk=
=dyZV
-END PGP SIGNATURE-




Re: use mocked

2007-02-23 Thread A. Pagaltzis
* Dominique Quatravaux <[EMAIL PROTECTED]> [2007-02-23 11:35]:
> And, uh, how about this:
> 
> use lib 't';
> use mock::LWP::Simple;

That will not call the importer in the right package.

Regards,
-- 
Aristotle Pagaltzis // 


Re: use mocked

2007-02-23 Thread Luke Closs

On 2/23/07, A. Pagaltzis <[EMAIL PROTECTED]> wrote:


* Dominique Quatravaux <[EMAIL PROTECTED]> [2007-02-23 11:35]:
> And, uh, how about this:
>
> use lib 't';
> use mock::LWP::Simple;

That will not call the importer in the right package.



To expand on this answer, without funky voodoo, after loading
mock::LWP::Simple perl won't think it had loaded LWP::Simple.  So later if
your module under test does 'use LWP::Simple', perl will load the real one.


Your approach does work when you're creating mock objects that are passed
into other objects, though.

Cheers,
Luke