How are people speccing and cuke-ing Paperclip (with S3)?

Hi – I’m running into all sorts of difficulties trying to use paperclip
with cucumber and rspec.

Basically, I’m stubbing out paperclip calls with WebMock (I’ve adapted
the
shoulda macro that uses FakeWeb to do this).

But every time I get things running smoothly, something else pops up to
screw things up.

The latest is a “Too many open files” error.

So how are other people speccing their paperclip code?

Please tell me they’re doing something, as I’m using S3 storage, which
would really slow my tests down if I just did nothing.

I’m starting to think of all sorts of horrible solutions, like making
the
storage strategy dependent on the environment, like using the file
system if
it is a test or cucumber env.

But I’d hate to resort to that.

Any & all advice really appreciated!

Cheers,

Doug.

PS – cross-posted at rspec and paperclip lists.

One of the things that you learn after testing for a while is “what to
test.” You don’t need to test Paperclip’s ability to put files to S3;
that’s
what Paperclip’s internal tests are for. So what I do is this:

http://gist.github.com/479647

When I’m developing locally or testing, I just write files to my local
machine. On production, they go to S3.

I was wary of taking an approach like that, as it feels a little like
test
code bleeding into production code, but the sheer number of problems I’m
having trying another way tells me that I’m very inadvisedly swimming
against the stream, here.
So I think I’ll rethink my strategy & try something more like this –
thanks!
Doug.

On 17 Jul 2010, at 5:58 PM, Steve K. wrote:

You don’t need to test Paperclip’s ability to put files to S3

It depends on your confidence in Paperclip (s/Paperclip/X random
library) and the severity of problem it could cause if it doesn’t work.
To me, at least, it’s more a risk/value judgement than a binary
decision. If millions of pounds rested on Paperclip uploading files to
the right place, I’d test the hell out of it before using it in my own
app!

Ash


http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

On 17 Jul 2010, at 5:43 PM, doug livesey wrote:

Please tell me they’re doing something, as I’m using S3 storage, which would really slow my tests down if I just did nothing.
I’m starting to think of all sorts of horrible solutions, like making the storage strategy dependent on the environment, like using the file system if it is a test or cucumber env.

For absolute confidence, you can use S3 for a full integration test.
You only need one of these for each type of interaction with S3 though.

For faster local integration tests, you could write a mock
implementation of S3.

I’ve not used Paperclip, but it looks like it works as a DSL embedded
into ActiveRecord class definitions. That’ll make it a lot harder to
separate out the file handling that if you were writing it out
explicitly.

Ash


http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran