# Help me with this test/mocks issue please!

**URL:** <https://www.ruby-forum.com/t/help-me-with-this-test-mocks-issue-please/149896>\
**Category:** Rails\
**Created:** [September 30, 2008, 10:36pm UTC](https://www.ruby-forum.com/t/help-me-with-this-test-mocks-issue-please/149896 "2008-09-30T22:36:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyfromky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e57/32.png) [@tonyfromky](https://www.ruby-forum.com/u/tonyfromky)\
**Post date:** [September 30, 2008, 10:36pm UTC](https://www.ruby-forum.com/t/help-me-with-this-test-mocks-issue-please/149896/1 "2008-09-30T22:36:34Z")

</div>

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?
