RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: yob
Ryan's suggested approach makes testing PDFs a breeze.
Create a new unit spec for the OrderPdf class and focus on the #render() method.
As a simple first step, spec that the render() methods returns a string that starts with "%PDF" to make sure it's generating a PDF.
To improve the specs, I'd check the PDF contains the appropriate text.
pdf = OrderPdf.new
reader = PDF::Reader.new(StringIO.new(pdf.render))
page = reader.page(1)
page.should include("order #1")