Testing private and protected methods with ruby

When I have to test my protected and private methods in ruby, I make the methods public for the scope of the test. MyClass.send(:public, *MyClass.protected_instance_methods) MyClass.send(:public, *MyClass.private_instance_methods) Just place this code in your testing class substituting your class name. Include the namespace if applicable.

Posted on April 18, 2007 at 12:48 pm by doug · Permalink · Leave a comment
In: Uncategorized · Tagged with: