From: Greg Willits Date: 2009-07-26T02:56:03+09:00 Subject: Re: Unit Testing and Instance Vars David A. Black wrote: > On Sat, 25 Jul 2009, Greg Willits wrote: >> private >> >> some_source.each do |this_source| >> end >> Either way, I still can't see the results of @raw_addresses. I find >> myself having to expose :raw_addresses so that tests can see the >> results, but there really is no need for :raw_addresses to be exposed, >> and it shouldn't be a part of the interface. >> >> Questions: >> 1) Any consensus on the parameters issue (*always* pass params, or >> *usually*)? >> 2) What's the 'best practice' approach to seeing the results of >> @raw_addresses? > > The key word, I think, is "interface", which in your example consists > of initialize and load_addresses. A year or so ago someone asked on > either this list or the Rails list about testing private methods, and > I said, yes, test all your private methods. David Chelimsky chimed in > with the observation that testing private methods is not generally > considered best practice; rather, the private methods are there to > help the class do what it has to do so that its public interface will > act correctly. Ah, yes. I recall reading some debates about that. When thinking about this, I was indeed going after the test all methods stance, but I actually like the idea of testing the interface. If changing an implementation doesn't break the application, it could be argued that it shouldn't break the tests either. -- gw -- Posted via http://www.ruby-forum.com/.