<div dir="ltr">Don't know if any of the tools already mentioned do something like this internally, but if not you could investigate perceptual hashing - think phash is a well known standard <a href="http://www.phash.org/">http://www.phash.org/</a><div><br></div><div>Something like this probably isn't really the right fit, because phashes are designed to be robust against transformations such as rotation etc. which you probably care about in this context; also it would probably be a lot of work to get implemented in a ruby test suite.<br></div><div><br></div><div>However, throwing it out there because you may find it an interesting approach/something to google more about - even if for its own sake and it turns out to be useless for your problem.</div><div><br></div><div>R</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:39 PM, Josh McMillan <span dir="ltr"><<a href="mailto:josh@joshmcmillan.co.uk" target="_blank">josh@joshmcmillan.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">I'm currently writing a bunch of smoke tests that involve checking the validity of machine generated PDFs. We use a multi-layer approach depending on how fast we want the suite to run:</div><div class="gmail_extra"><ul><li>Basic tests for the content in the document – checking the right text boxes etc are rendered in the right place. This is done with Prawn's pdf-inspector package: <a href="https://github.com/prawnpdf/pdf-inspector" target="_blank">https://github.com/<wbr>prawnpdf/pdf-inspector</a></li><li>Pixel-by-pixel comparison tests using ImageMagick (the `convert` tool can handle PDFs as if it they were images) with a level of tolerance: <a href="https://www.imagemagick.org/script/compare.php" target="_blank">https://www.<wbr>imagemagick.org/script/<wbr>compare.php</a></li></ul><div>In the event that there's a major difference between two PDFs as flagged by ImageMagick, we output a load of visual diffs (which can be done via `compare -verbose -metric RMSE -highlight-color <actual> <expected> <diff>`, see the above link) for validation by a human.</div><div><br></div><div>The validity of these PDFs is "mission critical" though (they get printed and sent to customers as a physical product that they've paid money for) so this is probably overkill for most scenarios.</div></div><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:29 PM, Mark Burns <span dir="ltr"><<a href="mailto:markthedeveloper@gmail.com" target="_blank">markthedeveloper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Yeah that's the kind of thing I was thinking.<div><br></div><div>I guess I may have been a bit too hopeful. No magical silver bullet shortcuts. </div><div><br>Just about getting as close as possible to automating the actual eyeballing of the doc.<br><br>diff-pdf sounded promising then:<br><br>```<br><div>$ diff-pdf book-1.pdf book-2.pdf<br>$ diff-pdf book-1.pdf book-2.pdf --verbose</div><div>page 1 differs</div><div>page 4 differs<br>```<br><br>Much better than nothing though :)</div></div></div><div class="m_7067664014687819567gmail-HOEnZb"><div class="m_7067664014687819567gmail-h5"><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 1, 2017 at 8:21 PM Gerhard Lazu <<a href="mailto:gerhard@lazu.co.uk" target="_blank">gerhard@lazu.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:small;color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif">A visual diff sounds most reasonable. Never used it myself, but <a href="https://github.com/vslavik/diff-pdf" target="_blank">https://github.com/vslavik/dif<wbr>f-pdf</a> is worth a try. And guess what? </span><font face="monospace, monospace" style="background-color:rgb(255,242,204)">brew install diff-pdf</font></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:00 PM, Mark Burns <span dir="ltr"><<a href="mailto:markthedeveloper@gmail.com" target="_blank">markthedeveloper@gmail.com</a>></span> wrote:<br></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Has anyone any recommendations or suggestions for testing PDF generation?<div><br></div><div>I'm working on a side project and using Prawn. Which is great. I can programmatically generate large aspects of the content I want.</div><div><br></div><div>But so far I've been tweaking then looking at the result in the browser.</div><div>It's not an absolute nightmare - a few seconds to render. But it's hard to know whether the result is working without actually looking at it.</div><div><br></div><div>The DSL is nice, but very imperative. Mocking method calls out would be insane.</div><div><br></div><div>I'm managing to refactor into small objects to represent the components and layout, pages, typography aspects etc of the document. Which brings the complexity back down to manageable chunks. <br><br>But ultimately everything just calls underlying prawn DSL methods. So I can test little bits of logic that I have in my objects, but ultimately whether it works or not comes down to "have a look and see".</div><div><br></div><div>Perhaps the best I can hope for is screenshotting when I'm happy and using approvals to verify each major change hasn't radically borked everything.</div><div><br></div><div>It seems like there are tools to test which strings get into the document, but that seems like the easiest part. And probably the only part I'd be happy with test doubles for prawn and setting expectations on the text generating methods.</div></div>
<br></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">______________________________<wbr>_________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermai<wbr>l/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.<wbr>cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo<wbr>.cgi/chat-lrug.org</a><br>
<br></blockquote></div></div></div>
______________________________<wbr>_________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermai<wbr>l/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.<wbr>cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo<wbr>.cgi/chat-lrug.org</a><br>
</blockquote></div>
</div></div><br>______________________________<wbr>_________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermai<wbr>l/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.<wbr>cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo<wbr>.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>______________________________<wbr>_________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/<wbr>pipermail/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.<wbr>cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/<wbr>listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br></div>