[rspec-users] Mocking expectations on I/O operations

Rob Aldred rob at stardotstar.com
Thu Sep 15 06:53:01 EDT 2011


 Hey Ash, 
I like the idea of a wrapper.
In fact I use this method for methods that need to shell out 

Maybe your right, the subdirectory would probably a better safer way of organising the temporary files.
I'll have a re-think.

Thanks for the info.

Rob 

--

On Thursday, 15 September 2011 at 11:08, Ash Moran wrote:

> 
> On 15 Sep 2011, at 10:05, Rob Aldred wrote:
> 
> > Thanks Justin,
> > That isnt working... its erroring with:
> > 
> > The method `delete` was not stubbed or was already unstubbed
> 
> Hi Rob
> 
> For reasons I could go into, when I'm coding myself I don't usually stub out file system access or other third party systems. Rather, I write an adapter that behaves in the way I expect and test it using the real file system, then test the rest of the system against a mock. That avoids this category of problem.
> 
> What you're doing here appears to be mixing both real (from mini_magick) and stubbed (your own library's) calls to filesystem code, and I think it's the asymmetry that's biting you.
> 
> I could explain the above in more detail*, but in lieu of that, here's another angle: can you run the code in a subdirectory per image and nuke that after? That way you only have one point to hit for the cleanup.
> 
> HTH
> 
> Ash
> 
> * As a quick example, you might have a TempFileCleaner object in place of IconGenerator#cleanup, seeded with all the potential temp filenames, or some algorithm to figure them out
> 
> -- 
> http://www.patchspace.co.uk/
> http://www.linkedin.com/in/ashmoran
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org (mailto:rspec-users at rubyforge.org)
> http://rubyforge.org/mailman/listinfo/rspec-users




More information about the rspec-users mailing list