我并不是非常关心测试文件上传,但由于我的模型中有validates_attachment_presence
等内容,因此rspec发出了警告。
所以现在我在spec中创建带有这些属性的模型,试图让它安静下来:
@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?