[rspec-users] specs on private methods

Matt Patterson matt-lists at reprocessed.org
Tue Jan 8 14:25:56 EST 2008


On 8 Jan 2008, at 19:14, Daniel Tenner wrote:


> Might be a personal thing, but my approach is that I try to test the
> public behaviour of the object. Testing private methods is, imho,
> getting dangerously close to specifying how the object does its
> business, rather than what it does.
>

If you're a proponent of many-skinny-methods then you wind up with a  
lot of public methods which should never need to be called by another  
object, so making them private can be a good thing for general users  
of the object.


> I would just spec the externally visible behaviour, where it occurs,
> and let the object implement it as it wants (using private methods or
> any other mechanism).
>

If the object were to implement it itself, that would be great ;-)  
Unfortunately, I have to implement the innards, and I'm rubbish so I  
like to test things...

Matt

-- 
   Matt Patterson | Design & Code
   <matt at reprocessed org> | http://www.reprocessed.org/




More information about the rspec-users mailing list