[rspec-users] uploads with webrat in stories

Jonathan Linowes jonathan at parkerhill.com
Fri Aug 29 13:19:19 EDT 2008


On Aug 29, 2008, at 12:52 PM, Ben Mabey wrote:

> Jonathan Linowes wrote:
>> I've read through the messages on this list, and have file upload
>> specs working in my model and controller tests, using :file =>
>> ActionController::TestUploadedFile.new(filepath)
>>
>> But its not working in stories using webrat. I've tried
>>
>>     fills_in "foo[file]", :with => filepath
>> and
>>     fills_in "foo[file]", :with =>
>> ActionController::TestUploadedFile.new(filepath)
>>
>> both fail (0) when submit
>>     clicks_button 'Update'
>>
>> oddly, in either case, a browser get opened, with something like
>> file:///Users/jonathan/rails/myproject/tmp/webrat-1220026536.html
>> which is blank
>>
>> suggestions?
>>
>> thx
>> linoj
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
> I haven't been able to get the webrat uploading method (attaches_file)
> to work.... If you haven't tried that method give it a shot, but I
> haven't gotten it to work.  To upload in stories I have done this:
>
> csv_file = .....
> file_to_upload = ActionController::TestUploadedFile.new(csv_file.path,
> Mime::CSV)
> post my_path, "import_file" => file_to_upload
>

i am trying that too, but at this point in my story i dont actually  
have the current record object to generate the form action path.
How would i extract the :action = path from the <form> in the current  
response.body ?

>
> In my story I didn't have other fields in the form so I didn't  
> bother to
> investigate why webrat wasn't working.. the clear disadvantage of the
> way I used is that I'm doing the post directly.
>
> -Ben
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list