DISQUS

Virtuous Code: Testing Private Methods

  • bryanl · 1 year ago
    I'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 ago
    Couldn'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 ago
    Or the `slugify` method could be turned into a function, since it isn't really relevant to the `BlogPost` instance.
  • avdi · 1 year ago
    Ruby 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 · 1 year ago
    Nice writeup. I agree with breaking out the code into separate classes here.