假货+轨道上的回形针3 + rspec2 会给我一个错误“无法生成临时文件”
导轨 (3.0.1)
fakefs (0.2.1)
回形针 (2.3.4)
rspec (2.0.1)
我正在使用 rspec 测试我的模型。 由于这是一个测试,我想防止像回形针通常那样在公共目录下创建任何文件。 我认为这个解决方法是使用 fakefs。
虽然我实现了这个
http://trevorturk.com/ 2008/12/11/easy-upload-via-url-with-paperclip/
能够从远程网址保存图像,如果我不把这一行
包含 FakeFS::SpecHelpers
来激活 fakefs在我的 rspec 中,如果我激活 fakefs,它工作正常(并且确实在 public/system 下创建文件...,我不想进行测试),
由于某些原因,我收到错误,例如
无法生成临时文件`/tmp /stream20101027-704-adna7o-9.gif'
在方法
def download_remote_image
self.image = do_download_remote_image
^ happening in this method
self.image_remote_url = image_url
end
/tmp权限是drwxrwxrwt,所以我认为任何人都可以在上面写。
这是我的问题。
- 我不应该使用 fakefs 来测试回形针相关的方法吗?
- 我是否应该不关心此类测试的回形针文件创建?或者还有其他方法可以解决问题吗?
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.
- Should I not use fakefs to test for paperclip related methods?
- Should I not care about the paperclip file creations for such tests? or there are any other ways to solve the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论