include ActionDispatch::TestProcess prevents guard from reloading properly

本小妞迷上赌 提交于 2019-12-10 13:28:30

问题


I'm using fixture_file_upload to test some file uploads in my rspecs

If I just put it in the spec I get an error for method not found.

To get it working I put include ActionDispatch::TestProcess in my spec but I have found since I did that, that guard is not correctly reloading spec files when I make changes, it keeps running the tests against the old version of the files.

I can work around this by stopping and restarting guard, but it kind of defeats the purpose.

How do I prevent this from happening? How should I reference fixture_file_upload or where should I put the include?


回答1:


I don't know the exact source of the problem, but I have had some strange issues caused by ActionDispatch::TestProcess myself. You can, however, use a workaround instead of fixture_file_upload, meaning you can remove the problematic include.

If you have something like this (e.g. in a factory):

include ActionDispatch::TestProcess

fixture_file_upload('spec/factories/test.png', 'image/png')

you can replace it with:

Rack::Test::UploadedFile.new('spec/factories/test.png', 'image/png')

If you look at the source of fixture_file_upload you'll see it essentially just calls the above code.



来源:https://stackoverflow.com/questions/18202261/include-actiondispatchtestprocess-prevents-guard-from-reloading-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!