"jason r tibbetts" <tibbettj / verdi.iisd.sra.com> schrieb im Newsbeitrag 
news:427BB35D.9050906 / verdi.iisd.sra.com...
> Caleb Tennis wrote:
>> Suppose I have this:
>>
>> class A
>> class B < A
>>
>> Now, in my unit tests, I create a mock object to use for testing 
>> purposes:
>>
>> class MockA < A
>>
>> What I need now is a MockB, which inherits from MockA
>>
>> class MockB < MockA
>>
>> But I still need all of the methods which I have previous defined inside
>> of B.  Note that MockB doesn't have any relation to the actual B, unless 
>> I
>> go back and redefine all of these methods within MockB itself.
>>
>> So, is there a way I can create a "MockB < B", but dynamically make "B
>> inherit from MockA instead of the real A"
>
> Do your mock classes define their own tests? If not, I'm not sure why 
> you'd need MockB to extend MockA, and certainly not B to extend MockA. 
> Make MockB extend B, which in turn extends A. If you really /must/ have 
> MockB extend MockA, you could wrap an instance of the latter inside the 
> former.

.... or use modules instead.  Hint: you can create instances with #alloc 
avoiding standard initialization.

module MockA
end

module MockB
  include MockA
end

tester = B.alloc
tester.extend MockB
....

Kind regards

    robert