How to find out if method was stubbed?

Skip to first unread message

Adam Cigánek

Oct 20, 2010, 6:53:38 AM10/20/10
to mocha-developer
Hello there,

Is there a way to find out if method was stubbed? Something like:

class Duck
def walk

def talk

duck =

duck.stubbed?(:walk) # should return true
duck.stubbed?(:talk) # should return false

If not, what would be the easies way to hack it in?

James Mead

Oct 22, 2010, 12:09:17 PM10/22/10
Hi Adam,

I don't think there's an easy way to do this at the moment.

I think either Mocha would need to keep a better handle on what
methods are being stubbed or you'd have to look for the original
hidden (i.e. renamed) versions of methods.

Out of curiosity, why do you want this functionality - it would be
interesting to see a real example of why it would be useful.

I've referenced your message from a ticket [1] in Lighthouse, because
I think it's related to the idea of un-stubbing.

Cheers, James.


> --
> You received this message because you are subscribed to the Google Groups "mocha-developer" group.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at

Reply all
Reply to author
0 new messages