タグ

ブックマーク / www.devroom.io (1)

  • RSpec'ing with Time.now · devroom.io

    I’m currently writing some RSpec tests that use Time.now. I want my model to calculate a duration and store the future time in the database. I’ve already specced the calculation of the duration, but I also want to spec that everything gets saved correctly. Here’s my first spec: 1it "should do stuff" do 2 m = Model.create() 3 m.expires_at.should eql(Time.now + some_value) 4end This fails. It fails

    ihag
    ihag 2010/08/02
    Time.nowにstub!を仕込むことで、Time.nowをフック。これはいいかんじ。
  • 1