perplexing functional test results

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

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'

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

Hi Craig,

Craig White 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 <snip>

Are you using fixture_file_upload ? If not, check it out at http://snipplr.com/view/1716/fixturefileupload-example/

HTH, Bill