R – Testing SWFUpload with Cucumber

cucumberruby-on-railsswfupload

In a project, I recently replaced a simple form-based file upload with SWFUpload. When SWFUpload returns a success, I generate a form to add tags to the uploaded asset.

I'd like to be able to test inputting data into the tags textbox, but to do that I (think I) need to fake out SWFUpload.

Has anyone done this in the past? I haven't been able to find anything via google, and there doesn't seem to be anything in the cucumber docs re: testing Flash.

Best Answer

I dont think you need to fake flash at all, because all swfupload is doing for you is simulating a simple http post.

If you do a manual http post to the same action/controller that your swfupload is posting to and make sure the file field of your post is named the same as the swf parameter which swfupload passes (params[:Filedata]) you should get the same effect.

Also to answer Swanand's comment above you need to hack CGI::Session. Try http://blog.isshen.com/2008/10/5/making-swfupload-and-rails-2-1-sessions-work-together