[rspec-users] Monitor method invoking from superclass

Rick DeNatale
Thu, 30 Sep 2010 13:56:28 -0000

On Thu, Sep 30, 2010 at 9:45 AM, David Chelimsky <dchelimsky at gmail.com>
wrote:
> On Sep 30, 2010, at 8:20 AM, Zhi-Qiang Lei wrote:

>>>> I want to if B is receive ''super'' message.
Thanks.
>>>
>>> I understand what you meant, but I don''t understand why
you want to do this. What is the bigger problem you are trying to solve? Why do
you want to monitor when super gets called?
>>
>> Thank you. Actually what I want is just to write a test case for it,
with rspec.
>
> You can not.

And following up on David''s reply, I don''t think you should,
Lei.

What you really should be testing that the observable effects of the
call are ''as if'' the super call were made.

If you could test that the super call was made it would be testing
that the implementation were a certain way more than the behavior of
the object, and that''s the road to writing brittle tests.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale