A few days ago, Jim Weirich sent me a beta of FlexMock (0.5.0.2) that includes a workaround for the dreaded rcov bus error. Before I even got finished testing it, Mauricio announced that Rcov was updated to 0.8, fixing the bus error. Sweet! FlexMock and Rcov are now playing nice again.
Now here is the next challenge. FlexMock's
new_instances (the 0.5.0.2 replacement for
any_instance) lets you mock all new objects of a class. As an implementation detail, I should note that it creates an eigenclass to do this. (Yes, I prefer the term eigenclass. Singleton is overloaded.)
The eigenclass should be an implementation detail, but because of a limitation of Ruby it is not. Eigenclass instances cannot be marshalled, so if you need to test objects that get thrown into a Rails session, the FlexMock approach will fail. Here's a challenge to you Rubyists out there: what's the best workaround for this particular problem? I think I have already decided on an approach but I would love to see what ideas the community comes up with.