我並不在乎測試文件上傳,但因爲我有validates_attachment_presence
等,在我的模型中,rspec在抱怨。測試用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?
可能重複[單元測試回形針上傳使用RSpec(滑軌)(http://stackoverflow.com/questions/2256012/unit-testing-paperclip-uploads-with-rspec-導軌) – 2011-09-19 07:32:25