On Sat, Apr 30, 2011 at 8:14 AM, Jeffrey L. Taylor <r...@abluz.dyndns.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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> 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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to