【发布时间】:2014-06-03 14:18:23
【问题描述】:
我正在编写一些 rspec 规范,其中对象的 widgetpic 字段需要指向实际图像,但没有使用载波上传器。
在测试的时候,我只想绕过上传器,手动设置一张测试图片的url。具体来说,我在网上有一些测试图像,只是想让foo.widgetpic.url返回一些固定位置:“http://mybucket.s3.amazonaws.com/test_pix/test1.png”
Widget 模型有:
mount_uploader :widgetpic, WidgetPicUploader
所以在我的 FactoryGirl 工厂中,我认为我需要做这样的事情
trait :test_pic do
SOMETHING "http://mybucket.s3.amazonaws.com/test_pix/test1.png"
end
我尝试设置 widgetpic_url 和 remote_widgetpic_url 但这不起作用(widgetpic.url 仍然返回我在上传器中定义的默认“无图像”图像)。
【问题讨论】:
标签: rspec carrierwave