【发布时间】:2010-07-28 23:47:52
【问题描述】:
我并不真正关心测试文件上传,但由于我的模型中有validates_attachment_presence 等。rspec 抱怨。
所以现在我正在使用规范中的这些属性创建我的模型来尝试关闭它:
@attr = {
:name => "value for name",
:title => "value for title",
:content => "value for content",
:pic_file_name => "example.jpg",
:pic_content_type => "image/jpg",
:pic_file_size => "8192",
:pic_updated_at => nil
}
不过,这不起作用。
我发现了这个:http://fr.ivolo.us/posts/mocking-paperclip-with-rspec 所以我尝试了这样的事情:
Post.should_receive(:save_attached_files).and_return(true)
这也不起作用。如何安抚 RSpec?
【问题讨论】:
标签: ruby-on-rails unit-testing rspec paperclip