Comments on: Your Private Methods are None of my Business https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/ Matt Wynne taking it one tea at a time Wed, 21 Aug 2019 13:02:06 +0000 hourly 1 https://wordpress.org/?v=6.2 By: DOug https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-893 Sun, 03 Jan 2010 20:19:09 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-893 You HOT>.. I’d lick that furry body all night long!

]]>
By: Me https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-784 Mon, 07 Sep 2009 18:06:31 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-784 I agree, the picture is disgusting. I’m about to puke my lunch!

]]>
By: Aki https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-678 Mon, 27 Jul 2009 07:05:13 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-678 Don’t listen to that jerk, the picture is beautiful! 🙂

]]>
By: Matt https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-663 Thu, 09 Jul 2009 13:07:24 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-663 @me – so is your language! Code that isn’t sufficiently encapsulated can be rather distateful too, IMO – that’s the point! 🙂

]]>
By: Me https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-662 Thu, 09 Jul 2009 09:33:58 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-662 The picture is fucking disgusting.

]]>
By: Matt https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-282 Fri, 07 Nov 2008 10:46:05 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-282 On the subject of testing private methods, I’m with Michael Feathers and Pat Maddox: If you feel the need to do it, you probably have a concern you need to separate into another class.

]]>
By: Daniel Lucraft https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-281 Fri, 07 Nov 2008 10:11:36 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-281 I agree in general, but in every particular case I end up too lazy to write specs that do things like model.send(:methodname) instead of model.methodname.

]]>
By: JM https://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/comment-page-1/#comment-280 Fri, 07 Nov 2008 10:02:33 +0000 http://blog.mattwynne.net/2008/11/07/your-private-methods-are-none-of-my-business/#comment-280 Good point Matt! Most people even hardcore TDD programmers like myself tend to forget about protected and private methods … The best way to remember them I guess is to feel the pain, like renaming a method and getting insulted by people impacted by your change 😉

Question, how do you test private & protected methods?

To be as DRY as possible, I wrote this (source code extracted from http://github.com/garnierjm/dry-report/tree/master/spec/spechelper.rb)


def changescopeofmethodtopublic(clazz, method)
eval("class #{clazz}
public(:#{method.to
s})
end")
end

then before calling a private / protected method:


changescopeofmethodtopublic(DontRepeatYourself::SimianRunner, :parameterexcludes)

I did that because the way I TDD is with very small methods (3-4 lines max) and very long and expressive names (viva La Autocompletion!). Sometimes I stub these small methods to go straight to the behavior I want to implement. Most of the times, it’s a 5-10 minutes job to write the specs for these tiny methods and make them pass …

]]>