Virtuous Code: Testing Private Methods
-
bryanl · 1 year agoI'm glad to have at least provided a little bit inspiration for this blog post. We totally see eye-to-eye on this matter.
-
Ben · 1 year agoCouldn't agree more. I often hear questions about testing private methods and to me it makes no sense whatsoever. As you say: private methods are an implementation detail!
-
Daniel Schierbeck · 1 year agoOr the `slugify` method could be turned into a function, since it isn't really relevant to the `BlogPost` instance.
-
avdi · 1 year agoRuby doesn't really support the notion of free functions (it kind of fakes it, but in a way I prefer not to take advantage of in anything but quick one-off scripts). It could be a class-level method, I suppose. I still prefer the class approach, because then if you decide to mock the slugification out you're not mocking methods on the class under test.
-
Craig Jolicoeur · 10 months agoNice writeup. I agree with breaking out the code into separate classes here.