On Sat, May 3, 2008 at 1:12 PM, Steve Downey <[EMAIL PROTECTED]> wrote: > Is there more precision than seconds in a Time instance? > > irb(main):006:0> a,b = Time.now, Time.now > => [Sat May 03 11:06:31 -0700 2008, Sat May 03 11:06:31 -0700 2008] > irb(main):007:0> puts a.to_i, b.to_i > 1209837991 > 1209837991 > => nil
This came up this morning in #rspec; Time tracks microseconds which blows up equality: >> a, b = Time.now, Time.now => [Sat May 03 13:15:31 -0500 2008, Sat May 03 13:15:31 -0500 2008] >> a == b => false >> [a.usec, b.usec] => [93308, 93309] Because of this, I tend to use 'should be_between()' when handling times; someone else suggested the .to_i trick which is probably closer to what is intended, but for some reason I find it confusing. k _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users