Mocking file downloads

A

Andrew Theaker

[Note: parts of this message were removed to make it a legal post.]

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
 
J

John Barnette

[Note: parts of this message were removed to make it a legal post.]

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.

http://github.com/chrisk/fakeweb


~ j.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top