# iain.nl  

Prawn and controller tests

Written on

There is a real annoying gotcha in using controller tests to test an action that renders a pdf with Prawn. You'll get a NoMethodException on "nil.downcase". The troubling part is that it totally puts you off by providing the wrong lines and backtrace.

This has been mentioned somewhere on some mailinglists, but to make it a bit more findable, I'd thought I'd post it here.

The solution workaround is to set the server protocol, like this:

it "should show the pdf" do
  request.env["SERVER_PROTOCOL"] = "http"
  get :show, :id => "report", "format" => "pdf"
  response.should render_template(:show)