[LRUG] Why does test invocation affect result?

Riccardo Tacconi rtacconi at gmail.com
Thu Sep 19 04:08:48 PDT 2013


Hi Andrew,

Regarding the first question I do not know what it could be the reason but
it must load something in a different way and/or the tests are not
isolated. For the second answer: you could test the PDFs using a
fingerprint of the file.


Riccardo


On 19 September 2013 11:59, Andrew Stewart <boss at airbladesoftware.com>wrote:

> Hello LRUG,
>
> I have a Rails 3.0 app which generates PDFs.  There are a couple of
> different themes which change how the PDF content looks, e.g. fonts,
> layout, etc.
>
> To test this I generated a reference PDF in each theme (via the first
> method below).  The tests generate the PDF again for each theme and verify
> the generated PDF and the respective reference PDF are identical (using
> FileUtils.identical?(a, b) ).
>
> The weird thing is one theme's test pass or fail depending on how you run
> the test.  Specifically the first two ways pass and the third fails:
>
> $ bundle exec ruby -Ilib:test test/unit/my_test.rb
> $ bundle exec rake test:units TEST=test/unit/my_test.rb
> $ bundle exec rake test:units
>
> The theme's reference PDF is 399582 bytes.  The last way produces a
> visually identical PDF of 399583 bytes.  When I diff the PDFs I get:
>
> 260c260
> < /BaseFont /AAAAAD+CaviarDreams
> ---
> > /BaseFont /AAAAAA+CaviarDreams
> 548c548
> < /BaseFont /AAAAAE+CaviarDreams-Bold
> ---
> > /BaseFont /AAAAAB+CaviarDreams-Bold
> 1235c1235
> < << /Length 5410
> ---
> > << /Length 5409
> 1240,1257c1240,1257
> [binary stuff snipped]
>
> So my first question is why am I getting different results?  And another
> question that comes to mind: is there a better way to test all this?
>
> Thanks in advance,
> Andy Stewart
> ----
> http://airbladesoftware.com
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>



-- 
Riccardo Tacconi
Ruby on Rails and PHP development - System Administration
VIRTUELOGIC LIMITED <http://www.virtuelogic.net/>

http://github.com/rtacconi
http://riccardotacconi.blogspot.com
http://twitter.com/rtacconi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130919/64ad6e6f/attachment-0003.html>


More information about the Chat mailing list