Does anybody know how to upload files in RoR Integration Tests? I have seen lots on simulating uploads with Functional and Unit tests, but all efforts I have made so far do not encode the files as multipart form-data so they end up as a string. I suspect I need to encode my post but don''t see how this can be done in the API. Any pointers would be greatly appreciated! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Check out : http://manuals.rubyonrails.com/read/chapter/28#page237 On 12/3/06, supagroova <supagroova-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Does anybody know how to upload files in RoR Integration Tests? > > I have seen lots on simulating uploads with Functional and Unit tests, > but all efforts I have made so far do not encode the files as multipart > form-data so they end up as a string. > > I suspect I need to encode my post but don''t see how this can be done > in the API. > > Any pointers would be greatly appreciated! > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Dec 04, 2006 at 03:13:02PM -0500, Bala Paranj wrote:> Check out : http://manuals.rubyonrails.com/read/chapter/28#page237that doesn''t help with integration testing, because the TestUploadedFile instance gets transformed into a string, yielding a NoMethodError (undefined method `content_type'' for "#<ActionController::TestUploadedFile:0xa6ff4848>":String) in the controller expecting an uploaded file. Jens> On 12/3/06, supagroova <supagroova-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Does anybody know how to upload files in RoR Integration Tests? > > > > I have seen lots on simulating uploads with Functional and Unit tests, > > but all efforts I have made so far do not encode the files as multipart > > form-data so they end up as a string. > > > > I suspect I need to encode my post but don''t see how this can be done > > in the API. > > > > Any pointers would be greatly appreciated! > > > > > > > > > > > >-- Jens Krämer jk-UayuY8ajoWPk1uMJSBkQmQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails Cookbook also has a recipe for testing file upload, you may want to check it out. Only rough cut version is available now. that doesn''t help with integration testing, because the TestUploadedFile> instance gets transformed into a string, yielding a > > NoMethodError (undefined method `content_type'' for > "#<ActionController::TestUploadedFile:0xa6ff4848>":String) >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sat, Dec 02, 2006 at 09:42:46PM -0800, supagroova wrote:> > Does anybody know how to upload files in RoR Integration Tests? > > I have seen lots on simulating uploads with Functional and Unit tests, > but all efforts I have made so far do not encode the files as multipart > form-data so they end up as a string. > > I suspect I need to encode my post but don''t see how this can be done > in the API. > > Any pointers would be greatly appreciated!I just built a small plugin for this - have a look at it there: http://www.jkraemer.net/2006/12/13/integration-test-your-file-uploads Jens -- Jens Krämer jk-UayuY8ajoWPk1uMJSBkQmQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---