doug livesey
2010-Jul-17 16:43 UTC
[rspec-users] 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 *some*thing, 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100717/85bc2ee0/attachment-0001.html>
Steve Klabnik
2010-Jul-17 16:58 UTC
[rspec-users] How are people speccing and cuke-ing Paperclip (with S3)?
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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100717/49676a72/attachment.html>
doug livesey
2010-Jul-17 17:32 UTC
[rspec-users] How are people speccing and cuke-ing Paperclip (with 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 July 2010 17:58, Steve Klabnik <steve at steveklabnik.com> wrote:> 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. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100717/ab4acba6/attachment.html>
Ashley Moran
2010-Jul-17 17:46 UTC
[rspec-users] How are people speccing and cuke-ing Paperclip (with S3)?
On 17 Jul 2010, at 5:58 PM, Steve Klabnik wrote:> You don''t need to test Paperclip''s ability to put files to S3It 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
Ashley Moran
2010-Jul-17 17:52 UTC
[rspec-users] How are people speccing and cuke-ing Paperclip (with S3)?
On 17 Jul 2010, at 5:43 PM, doug livesey wrote:> Please tell me they''re doing *some*thing, 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