Rails 2.3.11 DateTime BigDecimal Precision

I currently have a project in Ruby on Rails with Ruby 1.8.7 and Rails 2.3.2

I have some unit tests that read data from a database, in particular, a time column for two consecutive elements that should be 24 hours apart. In one test, I set the date-time for item 2 equal to the value of item 1.

When I make a statement to make sure that both values ​​are equal, the test works fine under rails 2.3.2. When I upgrade to rails 2.3.11, the tests do not show that the difference between the two points is turned off with the following error:

<Thu, 01 Jan 2009 06:00:00 CST -06:00> expected but was <Thu, 01 Jan 2009 05:59:59 CST -06:00>. 

There seems to be a problem with floating point conversions in two versions of rails. How can I take into account the floating point problem?

+6
ruby ruby-on-rails
source share
1 answer

This happened to me too, and I ended this:

 datetime.should be_a(Datetime) # maybe unnecessary datetime.to_s.should == expected_datetime.to_s 
+2
source share

All Articles