in reply to Mocking files for reading

I can't offer you any specific advice (I don't think you've told us enough for that), so consider this general advice that may, or may not, apply

If you consider the second point, it means you think about your test first and then code it. Then write some code that makes your program pass the test.

There's some really good reading in Extreme Perl.