Dear All,
Class B is a subclass of class A. Could anyone tell me how to monitor if
object created from class B receives a super message when its method is
invoked. Thanks.
Best regards,
Lei, Zhi-Qiang
Dear All,
Class B is a subclass of class A. Could anyone tell me how to monitor if
object created from class B receives a super message when its method is
invoked. Thanks.
Best regards,
Lei, Zhi-Qiang
On Sep 30, 2010, at 4:02 AM, Zhi-Qiang L. wrote:
Dear All,
Class B is a subclass of class A. Could anyone tell me how to monitor if object created from class B receives a super message when its method is invoked. Thanks.
I don’t know of a way to do that. What problem are you trying to solve?
Class A
def a
#some code
end
end
Class B
def a
#some code
super
end
end
I want to if B is receive ‘super’ message. Thanks.
On Sep 30, 2010, at 7:45 AM, Zhi-Qiang L. wrote:
On Sep 30, 2010, at 7:59 PM, David C. wrote:
On Sep 30, 2010, at 4:02 AM, Zhi-Qiang L. wrote:
Dear All,
Class B is a subclass of class A. Could anyone tell me how to monitor if object created from class B receives a super message when its method is invoked. Thanks.
I don’t know of a way to do that. What problem are you trying to solve?
[ I moved your post to the bottom. Please post at the bottom or in-line]
end
endI 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?
On Sep 30, 2010, at 9:15 PM, David C. wrote:
I don’t know of a way to do that. What problem are you trying to solve?
def a
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
Thank you. Actually what I want is just to write a test case for it,
with rspec.
On Sep 30, 2010, at 8:20 AM, Zhi-Qiang L. wrote:
Class B is a subclass of class A. Could anyone tell me how to monitor if object created from class B receives a super message when its method is invoked. Thanks.
Thank you. Actually what I want is just to write a test case for it, with rspec.
You can not.
Good luck,
David
On Thu, Sep 30, 2010 at 9:45 AM, David C. [email protected]
wrote:
On Sep 30, 2010, at 8:20 AM, Zhi-Qiang L. 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: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
On Thu, Sep 30, 2010 at 10:36 AM, Zhi-Qiang L. [email protected]
wrote:
On Sep 30, 2010, at 9:56 PM, Rick DeNatale wrote:
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.
In my case, there is already a test case for the method in class A, and its feature is complex. So I was trying to test the super call but observable effect for simple. Anyway, thank you both.
That’s what shared example groups are for.
–
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
On Sep 30, 2010, at 9:56 PM, Rick DeNatale wrote:
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
In my case, there is already a test case for the method in class A, and
its feature is complex. So I was trying to test the super call but
observable effect for simple. Anyway, thank you both.
Rick, could you elaborate on this? I’m curious, how would you use a
shared
example group here, given his sample code?
My first thought was to use ancestors to get the parent class, and
re-define
the ‘a’ method there to do something simple and observable, and then
test
that. Is that evil?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs