views:

28

answers:

1

Hi, I have a quite long method. It copy an ActiveRecord object with all relations, and changes relations in some cases. To make code more readable, I use private methods. I would like to test them. Technicaly, in Ruby it is no problem, but I suspect, I have bad design. Do you have any advices how to deal with such case?

+4  A: 

One school of thought is that each and every private method that matters should be tested implicitly by testing a class's public interface. If a private method didn't get called through the public interface, it is redundant. If your private method is that complex to require its own tests, you should consider putting it in a class of its own and test that class.

In short, it shouldn't be necesary to explicitly test your private methods.

as the saying go's: "Don't touch your privates."

Lieven
You said all that just so you could do that joke at the end...
Max Williams
Who said it was a joke? <vbg>
Lieven