[LRUG] Why does test invocation affect result?
Andrew Stewart
boss at airbladesoftware.com
Thu Sep 19 12:11:27 PDT 2013
Solved!
Riccardo, you were right: the tests weren't isolated. However the culprit wasn't my test code per se but third-party code:
https://github.com/prawnpdf/ttfunk/blob/master/lib/ttfunk/table/name.rb#L46-L52
It seems to me that TTFunk, used by Prawn, holds a font counter (subset_tag) in a class variable. When I run multiple tests Prawn and TTFunk remain loaded in the process and so the class variable is never reset.
My solution is to crowbar the counter back to its starting value at the start of each test:
::TTFunk::Table::Name.class_variable_set :@@subset_tag, 'AAAAAA'
Inelegant but effective.
Paul, I like your way of reframing the problem and would have gone with it had I not managed to get my initial approach to work. Thanks for the suggestion.
Yours,
Andrew
More information about the Chat
mailing list