How to find out if method was stubbed?

8 views
Skip to first unread message

Adam Cigánek

unread,
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
end

def talk
end
end

duck = Duck.new
duck.stubs(:walk)

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

unread,
Oct 22, 2010, 12:09:17 PM10/22/10
to mocha-d...@googlegroups.com
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.
----
http://blog.floehopper.org/

[1] http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/69-allow-unstubbing-of-methods#ticket-69-5

> --
> You received this message because you are subscribed to the Google Groups "mocha-developer" group.
> To post to this group, send email to mocha-d...@googlegroups.com.
> To unsubscribe from this group, send email to mocha-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mocha-developer?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages