[rspec-users] specs on private methods

Daniel Tenner daniel.ruby at tenner.org
Wed Jan 9 05:11:18 EST 2008

Just to clarify, this is what I meant in my original email :-) Most  
of my methods are very small - in Ruby any method longer than 5 lines  
is, imho, a code smell that's waiting to be fixed. However, no matter  
how many methods are used to implement the functionality, I test the  
public behaviour of the object rather than the methods themselves.  
Sometimes, this maps directly to a public method. Sometimes, a spec  
will actually use several public methods in concert. With this  
approach, I never spec private methods.


On 9 Jan 2008, at 10:01 9 Jan 2008, Stefan Magnus Landrø wrote:

> I totally agree with you, David!
> For quite a while I was testing all my methods (even had to declare  
> them protected/package scope in java!), but I realized that I was  
> getting into a lot of trouble. Now I've shifted to testing  
> functionality in stead of methods.
> Now, sometimes you might end up having small methods (typically a  
> result of refactoring) that are being used by several clients. In  
> that case you should start testing those methods, since they  
> actually represent real business logic.
> I talked to uncle Bob about this issue just a few months ago, and  
> as far as I understood, he uses a similar approach.
> I think it might make sense to think of the facade pattern when you  
> do your testing - do you really care what happens behind the facade?
> Stefan
> 2008/1/9, David Chelimsky <dchelimsky at gmail.com>:
> On Jan 8, 2008 1:25 PM, Matt Patterson <matt-lists at reprocessed.org>  
> wrote:
> You should check out the bowling kata
> ( http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata) if you
> haven't. At the end there are just a few tests and they all touch only
> 2 public methods, but there are many, many smaller methods that appear
> through refactoring. They are all thoroughly tested, though not
> directly.
> Cheers,
> David
> ______________
> -- 
> Bekk Open Source
> http://boss.bekk.no
> _______________________________________________
> 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/20080109/eb7c2f0a/attachment.html 

More information about the rspec-users mailing list