# Perplexing functional test results

**URL:** <https://www.ruby-forum.com/t/perplexing-functional-test-results/138705>\
**Category:** Rails\
**Created:** [May 27, 2008, 1:03am UTC](https://www.ruby-forum.com/t/perplexing-functional-test-results/138705 "2008-05-27T01:03:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [May 27, 2008, 1:03am UTC](https://www.ruby-forum.com/t/perplexing-functional-test-results/138705/1 "2008-05-27T01:03:40Z")

</div>

I’m getting pretty far with functional testing and have run into a  
situation where I’m checking a method that ‘stamps’ db data into form  
fields on a PDF file.

I have 6 such methods in my ‘ClientsController’ and half the tests  
fail…

def test\_rhba\_signoff\_form  
login\_with\_administrator  
get :rhba\_signoff\_form, :id =\> 3  
assert\_response 302  
end

the failure is I get response 200 (which is a failure). test.log also  
clearly shows a 200 result.

so I fired up ‘webrick -p 7000 -e test’ and used a browser and was able  
to get these stamped PDF’s without a problem. (obviously not a 200)

3 of these same methods test without error but 3 methods test  
consistently with this error and there’s very little difference between  
them except the data fields so I made sure that when I tested against  
webrick, I used the same ‘id =\> 3’ record and there’s no problem.

I would really like to include this in my testing…is there some  
better/more reliable way to test for a response which isn’t a template  
response but rather a

send\_file “tmp/SOME.pdf”, :type =\> “application/pdf”, :disposition =\>  
‘inline’

That clearly delivers except in testing?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [May 27, 2008, 1:21am UTC](https://www.ruby-forum.com/t/perplexing-functional-test-results/138705/2 "2008-05-27T01:21:15Z")

</div>

On 27 May 2008, at 00:02, Craig W. wrote:

> between  
> them except the data fields so I made sure that when I tested against  
> webrick, I used the same ‘id =\> 3’ record and there’s no problem.
> 
> I would really like to include this in my testing…is there some  
> better/more reliable way to test for a response which isn’t a template  
> response but rather a
> 
> send\_file “tmp/SOME.pdf”, :type =\> “application/pdf”, :disposition =\>  
> ‘inline’

send\_file will result in 200, not a 302 (which only happens with a  
redirect - not what you are doing here).  
You could check the content type or the response body

Fred

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [May 27, 2008, 1:41am UTC](https://www.ruby-forum.com/t/perplexing-functional-test-results/138705/3 "2008-05-27T01:41:44Z")

</div>

Hi Craig,

----- Original Message -----  
Craig W. wrote:

> the failure is I get response 200 (which is a failure).

i don’t mean to “butt in” to your conversation with Fredrick, but what  
do  
you mean by “response 200 (which is a failure)”. If you mean that you  
were  
expecting a 302 and your test failed because you got a 200 which is  
‘successful’, OK. Otherwise…

> so I fired up ‘webrick -p 7000 -e test’ and used  
> a browser and was able to get these stamped PDF’s  
> without a problem.

Exactly. A 200 means the action succeeded. As you saw in the browser.

> I would really like to include this in my testing…is there  
> some better/more reliable way to test for a response  
> which isn’t a template response but rather a

Are you using fixture\_file\_upload ? If not, check it out at  
[http://snipplr.com/view/1716/fixturefileupload-example/](http://snipplr.com/view/1716/fixturefileupload-example/)

HTH,  
Bill
