Chi*_*tan 11 testing attachment-fu ruby-on-rails ruby-on-rails-3
我正在尝试使用attachment_fu为工作文件上传功能编写规范.但是,作者提供的用于测试的示例代码要求我要求action_controller/test_process以便我可以访问ActionController::UploadedStringIO类.我之前在rails 2.x中使用过这个,但对于rails 3,它无法找到test_process文件.
如何继续测试rails 3中的文件上传功能?
Mel*_*ers 23
我能够在Rails3和rspec上使用fixture_file_upload.
我刚刚添加include ActionDispatch::TestProcess到spec_helper.rb,然后传递类似下面的内容作为filedata:
fixture_file_upload(Rails.root.join("spec/support/test.png"), 'image/png')
Run Code Online (Sandbox Code Playgroud)
编辑:我升级的东西改变了这个行为总是包括fixtures路径,所以我切换到这个而不是fixture_file_upload:
Rack::Test::UploadedFile.new(Rails.root.join("spec/support/test.png"), 'image/png')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3583 次 |
| 最近记录: |