Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include ActionDispatch::TestProcess prevents guard from reloading properly

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?

like image 421
ChrisJ Avatar asked Aug 13 '13 06:08

ChrisJ


1 Answers

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.

like image 161
lime Avatar answered Oct 27 '22 00:10

lime