Testing send_file

9 views
Skip to first unread message

Tom Cocca

unread,
Oct 10, 2009, 10:53:29 AM10/10/09
to shoulda
Anybody have any good clean ways to test send_file in a controller?

This is all I can find on google: http://d.hatena.ne.jp/falkenhagen/20090702/1246503899

Any nicer ways to test this?

Thanks,
~ Tom

Dan Croak

unread,
Oct 10, 2009, 1:44:30 PM10/10/09
to sho...@googlegroups.com
That article suggests the goal is to test the "contents" of the file.
That is a slightly different concern than what I would usually
consider "testing for send file in a controller", which I typically
understand as: was the response what I expected?

# ...
get :show, :id => @report.to_param, :format => "pdf"
end

should_respond_with :success
should_respond_with_content_type "application/pdf"

or:

# ...
get :show, :id => @ticket.to_param, :format => "gif"
end

should_respond_with :success
should_respond_with_content_type "image/gif"
--
Dan Croak
@Croaky
Reply all
Reply to author
Forward
0 new messages