Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

A fresh new module on CPAN: Test::MockFile::Light

by mayaTheCat (Scribe)
on Sep 10, 2007 at 14:53 UTC ( [id://638090]=perlmeditation: print w/replies, xml ) Need Help??

Hi Monks,

In a recent post Mocking files for reading, I asked some questions on how to mock files. I was trying to develop a module which mock files without accessing the actual file system. The motive is to test file operations without accessing the file system.

Using your answers I finalized my module, and put on CPAN: Test-MockFile-Light

I hope the community will find it helpful.

Thanks for your help,
Oguz

---------------------------------
life is ... $mutation = sub { $_[0] =~ s/(.)/rand()<0.1?1-$1:$1/ge };

Replies are listed 'Best First'.
Re: A fresh new module on CPAN: Test::MockFile::Light
by shmem (Chancellor) on Sep 10, 2007 at 21:05 UTC
    Nice work - but...
    a rose is a rose is a rose -- Gertrude Stein

    why would I mock it?

    why would I mock a file, since everything is a file?

    Your module is a file,
    $0 is a file, perl is a file,
    the content of __DATA__ is a file within a file,
    and the content of a "mock file" certainly is - a file...

    *scratch_head*

    Could you outline a scenario where this module might be useful?

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      You may be right, but ...

      ... I like minimalism; Although we all live in a sea of files - namely the file system - I do not like to create small temporary files which will only exist during script run.

      A possible scenario is that you have a module which writes formatted data on some file, and you want to test the module, in which case you need to test the content of the file. You can use the module to mock file during testing.

      You can find examples on the documentation of Test-MockFile-Light.

      Oguz

      ---------------------------------
      life is ... $mutation = sub { $_[0] =~ s/(.)/rand()<0.1?1-$1:$1/ge };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://638090]
Approved by kyle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-25 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found