[rspec-users] Testing file attachment with Paperclip

Rick DeNatale rick.denatale at gmail.com
Mon Jun 9 17:18:51 EDT 2008

On Mon, Jun 9, 2008 at 8:18 AM, Nicholas Wieland <nicholas.wieland at gmail.com>

> Il giorno 09/giu/08, alle ore 14:11, David Chelimsky ha scritto:
>  On Jun 9, 2008, at 7:05 AM, Nicholas Wieland wrote:
>>  Does someone have an example on faking a file upload for just ensuring it
>>> gets called
>> http://talklikeaduck.denhaven2.com/articles/2008/04/18/rails-integration-test-file-upload-plugin
> I haven't been clear enough, my point is not to fake the file upload
> (there's also fixture_file_upload for that) but to fake the receiver, making
> it dumb enough to avoid performing every operation on the file (in my case,
> uploading to s3).

I'm pretty sure the problem is that by the time you stub has_attached file,
which is a class method run when the class is loaded, it's too late.  Based
on a quick look at the paperclip project site, it looks like what you want
to stub is the save_attached_files method on the model INSTANCE, which the
has_attached_file registers as an after_save callback.
Rick DeNatale

My blog on Ruby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080609/ed0d6909/attachment.html>

More information about the rspec-users mailing list