Mocking file downloads

I’m developing a data loading for work and I’m using RSpec as my testing
framework. One feature of the tool is that it downloads any required
data
files that are missing from the local filesystem from a website.

I have a test case that sets up a situation where a data file is should
be
downloaded, but I don’t want the test to actually get the file from the
website as the files are quite large and take a while to download,
slowing
down the internet connection.

I’ve started looking into options for testing this functionality without
the
download. My current idea is to set up a local webserver as part of the
test, maybe using Sinatra, and point my tool at it for the downloads.
I’m
not sure that this feels like the best option? Is there a way to do this
with Mock objects? Any suggestions would be very much appreciated.

This is also my first time using RSpec, so if I did go down the path of
setting up a Sinatra webserver to download the files from, where is the
best
place to set it up? Should I create it in my spec file, or does it
belong in
the spec_helper?

Cheers,
Andrew Theaker

On Apr 3, 2010, at 4:53 PM, Andrew Theaker wrote:

I have a test case that sets up a situation where a data file is should be
downloaded, but I don’t want the test to actually get the file from the
website as the files are quite large and take a while to download, slowing
down the internet connection.

~ j.