Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Created June 26, 2011 05:06
Show Gist options
  • Save tjmcewan/1047266 to your computer and use it in GitHub Desktop.
Save tjmcewan/1047266 to your computer and use it in GitHub Desktop.
rspec
(rdb:1) date
2010-09-26 05:02:10 UTC
(rdb:1) date.class
Time
(rdb:1) @league.rounds.current.start_date.utc
2010-09-26 05:02:10 UTC
(rdb:1) @league.rounds.current.start_date.utc.class
Time
(rdb:1) @league.rounds.current.start_date.utc == date
false
#AND THE SOLUTION IS:
(rdb:1) @league.rounds.current.start_date.utc.should be_within(1).of(date)
true
# Cheers to @ryanbigg, @vowel_boy, @ivanvanderbyl, & @pda :-D
@pda
Copy link

pda commented Jun 26, 2011

Looks like Time has a #usec method, but the microseconds being stored aren't shown in #to_s. As a workaround you could try:

@league.rounds.current.start_date.utc.should be_within(1).of(date)

or just

@league.rounds.current.start_date.utc.to_i.should eq(date.to_i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment