A: 

My initial guess would be that the value of Time.now is formatted differently from your database value.

Tobes Atwork
+1  A: 

You should mock the now method of Time to make sure it always match the date in the spec. You never know when a delay will make the spec fail because of some milliseconds. This approach will also make sure that the time on the real code and on the spec are the same.

If you're using the default rspec mock lib, try to do something like:

t = Time.parse("01/01/2010 10:00")
Time.should_receive(:now).and_return(t)
robertokl
A: 

Are you sure that you are using == and not eql or be? The latter two methods use object identity rather than comparing values.

From the output it looks like the expected value is a Time, while the value being tested is a DateTime. This could also be an issue, though I'd hesitate to guess how to fix it given the almost pathological nature of Ruby's date and time libraries ...

zetetic
Yeah, definitely using ==.
lobati
Do you get the same output when using DateTime instead of Time?
zetetic