Question: How to test pdf content generated by prawn-table


How to test pdf content generated by prawn-table

Answers 0
Added at 2016-12-23 13:12

pdf-inspector provides some useful methods for testing PDFs generated by Prawn. While testing strings is straightforward, I need a way to test that tables (generated by prawn-table) are generated correctly.

For example, I'm generating a table

rows = ['Name','Value']
@objects.each do |object|
rows << [, object.value]

I would like to include something like the following in a test

let(:object} { create :object, name: 'Object', value: 10 }
let(:my_pdf) { #params ) }

it { expect(PDF::Inspector::Text.analyze( my_pdf ).strings ).to include "Object 10" }

This does not work because prawn-table does not generate this as a single string, but as "Object", "10".

Are there any libraries out there that people recommend for testing content generated by prawn-table. Or is there a standard way to do this?

Source Show
◀ Wstecz