I find myself in a somewhat unique situation. I'm using SDWebImage to make requests that utilize the
Cloudinary Image Transformation API. Since the quantity of images is low I'm having the SDWebImagePrefetcher initiate the prefetching of all images as soon as the final size of the imageview in my tableviewcell is known (which as far as I can tell is tableView:willDisplayCell:forRowAtIndexPath:). Since that method is called very frequently, I put the prefetch call in a dispatch_once() block. In the dispatch_once template, and most implementations I've seen, the token is declared statically right before the dispatch_once. Given that this view controller is my initial view controller and I'm running as a test bundle, this token is spent before any of my specs run. To combat this, I have declared it outside the @implementation block in the .m file. In spec I can extern the token and reset it before invoking the tableView:willDisplayCell:forRowAtIndexPath:
This solution makes it testable, but feels "yucky". Is there a well established pattern around testing these types of situations? I realize this situation is oddly specific, but I suspect there may be a generally better way to handle these tokens.
Thanks,
-Jason