← Back to Upcase

Meditations on a Class Method


(Samnang Chhun) #1
def self.run(user)
  new(user).run
end

I have read a thoughtbot’s blog post today http://robots.thoughtbot.com/meditations-on-a-class-method

I feel I like this style because it helps me simplify caller interface, so we could stub/mock it easier. What is your opinion on class methods like this?


(Andy Waite) #2

Yeah, I’ve been doing this for a while, I don’t remember where I originally picked it up. It’s especially useful in tests so that you don’t need to have a mock returning another mock, (or stub_chain in RSpec).