[RSpec] Stubbing Time.now

Tadashi Shigeoka ·  Tue, March 26, 2013

A memo on code for stubbing Time.now in Ruby on Rails + RSpec.

time_now = Time.local(2013, 12, 31, 0, 0, 0)
Time.stub!(:now).and_return(time_now)

That’s all from the Gemba.