I have a class called X that writes to disk. For this reason, the class is hard to test. If it wrote to a hash instead, I could test it.
So I made a new class called X in test/mocks. In that class, I overrode the methods that wrote to disk.
But I didn't want to copy ALL the methods from the real X into the mock X - only the ones that were being over-ridden.
My idea was to subclass the mock X from the real X and only define/ cripple the poisonous file-based methods.
However, it doesn't work ![]()
The problem is that I don't know how to subclass from the real X:
def X < X ... end
...doesn't cut it! Assuming the real X lives in (proj)/lib/this/ that, how can I subclass from it?