Sunday, January 4, 2009

A tip from a Tortise

How to call private/protected methods from tests:

Calling a private method is easy enough to do it when eeded but also
ugly enough to prevent you overdoing it:

obj.send :my_private_method, arg_foo, arg_bar


Also, if you define the method as static (self.method_name) you can
call it in exactly the same way:

ClassName.send :my_private_method, arg_foo, arg_bar

No comments:

Post a Comment