views:

39

answers:

0

rails (3.0.1)
fakefs (0.2.1)
paperclip (2.3.4)
rspec (2.0.1)

I am testing my model with rspec. Since this is a test, I want to prevent any file creations under the public directory as paperclip normally does. I am thinking this workaround is to use fakefs.

Although I implemented this

http://trevorturk.com/2008/12/11/easy-upload-via-url-with-paperclip/

to be able to save an image from a remote url, if I don't put this line

include FakeFS::SpecHelpers

to activate fakefs in my rspec, it works fine (and DOES create files under public/system..., which I don't want for tests)

if I activate fakefs, for some reasons, I get an error such as

cannot generate tempfile `/tmp/stream20101027-704-adna7o-9.gif'

at the method

  def download_remote_image
    self.image = do_download_remote_image
          ^ happening in this method
    self.image_remote_url = image_url
  end

/tmp permission is drwxrwxrwt, so I think anyone can write on it.

and here are my questions.

  1. Should I not use fakefs to test for paperclip related methods?
  2. Should I not care about the paperclip file creations for such tests? or there are any other ways to solve the problem?