# Testing question

**URL:** <https://www.ruby-forum.com/t/testing-question/151062>\
**Category:** Rails\
**Created:** [October 16, 2008, 1:23pm UTC](https://www.ruby-forum.com/t/testing-question/151062 "2008-10-16T13:23:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franz\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ecb155/32.png) [@Franz\_S](https://www.ruby-forum.com/u/Franz_S)\
**Post date:** [October 16, 2008, 1:23pm UTC](https://www.ruby-forum.com/t/testing-question/151062/1 "2008-10-16T13:23:55Z")

</div>

Hello folks,

I need to write a method that will return a PDF to the user.

Does anyone know of any documentation on how to test  
such functionality?

Thanks in advance.

Regards,  
Franz

---

<div class="post-metadata">

**Author:** ![Franz\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ecb155/32.png) [@Franz\_S](https://www.ruby-forum.com/u/Franz_S)\
**Post date:** [October 16, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/testing-question/151062/2 "2008-10-16T15:21:37Z")

</div>

Franz S. wrote:

> Hello folks,
> 
> I need to write a method that will return a PDF to the user.
> 
> Does anyone know of any documentation on how to test  
> such functionality?

I haven’t needed to do such a thing so I’m of limited help. I suppose  
if you’re doing downloads using rails then you’ve probably looked at the  
streaming api:  
ActionController::Streaming  
The send\_data/send\_file methods allow you to set the content-type and  
other headers etc etc.

So in your functional tests for your download controller, you could  
probably do something like

def test\_1a  
…  
get :download , params  
assert\_equal ‘text/html’,@response.headers[:type]  
…

(Obviously replace ‘text/html’).  
You can also access other headers eg content-length and the body  
(@response.body).  
I don’t know if it’s good form to be using @response.  
Integration test api is a little different so might be worth checking  
too.

Daniel
