Stubbing out S3 calls in Paperclip

Here’s a quick tip for people using Paperclip that I mentioned on the Google Group. You can easily stub out calls to S3 in your tests using mocha like so:

Photo.any_instance.stubs(:save_attached_files).returns(true)
Photo.any_instance.stubs(:destroy_attached_files).returns(true)

Of course, you’d want to change the Photo bit depending on the model you have using Paperclip.

Hopefully this little tip will save others the fruitless Googling and annoying code digging I did🙂

Published by

Trevor Turk

A chess-playing machine of the late 18th century, promoted as an automaton but later proved a hoax.

5 thoughts on “Stubbing out S3 calls in Paperclip”

Comments are closed.