small medium large xlarge

10 Nov 2015, 22:35
Steven Hicks (1 post)

I’m following along with the book and I get to the part where we’ve just finished writing our first test and now we’re running rake test. As expected the test fails. My test failed because:

Expected /PDF/ to match "", not Expected /PDF/ to match "This template is rendered with Prawn.\n". like it does in the book.

My response.body is nil. In fact if I puts response in pdf_renderer/test/integration/pdf_delivery_test.rb before the test gets to assert_match "PDF", response.body I am returned:

DEPRECATION WARNING: `ActionDispatch::Response#to_ary` no longer performs implicit conversion to an array. Please use `response.to_a` instead, or a splat like `status, headers, body = *response`. (called from puts at ~/crafting_rails_4_applications/pdf_renderer/test/integration/pdf_delivery_test.rb:8)
{"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff", "Content-Type"=>"application/pdf; charset=utf-8", "Cache-Control"=>"no-cache", "X-Request-Id"=>"9192ed4a-857b-4ce7-92b3-5f53fb9d8ffd", "X-Runtime"=>"0.017721", "Content-Length"=>"0"}

body isn’t included in response.

From here, if I ignore the fact that my test failed because Expected /PDF/ to match "" != "Expected /PDF/ to match "This template is rendered with Prawn.\n"" and move forward to adding the code pass the test in pdf_renderer/test/lib/pdf_render.rb, my test still won’t pass.

Furthermore, it seems if I comment out assert_match "PDF", response.body, the next assertion fails and each assertion that follows fails too. What am I doing wrong?

Plz Halp!

You must be logged in to comment