How can download of files be tested? The processing of the file is being tested okay, but I don''t know how to simulate the controller call. TIA, Jeffrey -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sat, Apr 30, 2011 at 8:14 AM, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>wrote:> How can download of files be tested? The processing of the file is being > tested okay, but I don''t know how to simulate the controller call. >What are you using to test? This is a bit off your topic as it sounds like you are writing controller specific tests. I used to do that, but in the last year I have started convering my ui and views heavily with testing and since doing this I find that I can achieve reasonably also testing the controller actions. I am sure some will argue against this but in the interest in time and quality I think I get more bang for my time covering how the user will use my ui. That said, I use rspec with capybara (steak) and using capybara, if there is a download link, I just click the link and then look at the page.body which gives me the content of the downloaded file. I know you should be able to do so in a controller spec/test also, should be something like calling a get. I am not sure what your method is but if it has multiple formats then you would have to specify the format in a parameter I think, or do something like "get ''/controller/action/file.pdf" or something like that. I would google for ''rails test file download'', it looks like you will have some results you can at least piece together.> > TIA, > Jeffrey > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Quoting David Kahn <dk-rfEMNHKVqOwNic7Bib+Ti1W1rNmOCjRP@public.gmane.org>:> On Sat, Apr 30, 2011 at 8:14 AM, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>wrote: > > > How can download of files be tested? The processing of the file is being > > tested okay, but I don''t know how to simulate the controller call. > > > > What are you using to test? This is a bit off your topic as it sounds like > you are writing controller specific tests. I used to do that, but in the > last year I have started convering my ui and views heavily with testing and > since doing this I find that I can achieve reasonably also testing the > controller actions. I am sure some will argue against this but in the > interest in time and quality I think I get more bang for my time covering > how the user will use my ui. That said, I use rspec with capybara (steak) > and using capybara, if there is a download link, I just click the link and > then look at the page.body which gives me the content of the downloaded > file. > > I know you should be able to do so in a controller spec/test also, should be > something like calling a get. I am not sure what your method is but if it > has multiple formats then you would have to specify the format in a > parameter I think, or do something like "get ''/controller/action/file.pdf" > or something like that. I would google for ''rails test file download'', it > looks like you will have some results you can at least piece together. >Oops, I have the directions backwards. I need to simulate/test upload of a file. The user is uploading their RSS feeds in an OPML file (typically exported from Google Reader). I expected this to be an obscure question, so I didn''t Google it. It isn''t. There are several answers on Stack Overflow and elsewhere. I sucessfully used the answer at the URL below. Note, this has changed in Rails 3. There is a link to the Rails 3 answer in the footnote to the first answer. Jeffrey -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.