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. Yi On Fri, Oct 10, 2008 at 2:40 PM, Anita Anita <[EMAIL PROTECTED]> 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@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users