[rspec-users] private methode

Yi Wen hayafirst at gmail.com
Fri Oct 10 16:07:49 EDT 2008

IMHO, one should never directly test a private method. So I prefer the
second way you mentioned in your email.

Better yet, think of why you want to test a private method. Is it too
complicated? If this is the case, way too often this private method should
not really belong to the class it's currently in. This class might be doing
too much and this private method is not part of core functionality this
class provides (or else it should be made public as part of the class's
interface). So you may want to refactor the code to find a proper home for
your private method and make it public in that class and you can unit
testing this new public method.


On Fri, Oct 10, 2008 at 2:40 PM, Anita Anita <lists at ruby-forum.com> wrote:

> Hi,
> Can I test private methods directly?
> Or should I pass by the methods that are calling these private methods?
> Or can I make the method private after testing?
> What is the best way?
> Thank you
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081010/7f51ad61/attachment.html>

More information about the rspec-users mailing list