Skip to content
Paweł Gościcki

Paweł Gościcki

Random pieces of code, thoughts and movie reviews

Pages

  • Movie reviews
  • Projects
    • WP Movie Ratings

Recent movies

  • Gravity Falls S01 (TV Series, 2012)
    * * * +

    Watchable. Quite funny at times. It feels like an older (i.e. dated) brother to Rick and Morty.

  • Primal S03 (TV Series, 2026)
    * * * *

    Still pretty good.

  • Teściowie 3 / The in-laws 3 (2025)
    * * *

    Watchable.

All movie ratings »

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Month: February 2013

Stubbing Time.current in Ruby specs

Yeah, sure, we could do that. We could also use timecop. But both solutions seems overkill when all you need is to check if some attribute got updated with the result of `Time.now`. What you should do instead, is use the power of RSpec (or rspec-expectations to be more exact):

expect(post.published_at).to be_within(1.second).of(Time.current)

Doesn’t it look just beautiful?

Posted on February 25, 2013June 19, 2022Categories programming, ruby
Proudly powered by WordPress