Forum: Ruby on Rails assert_equal fails on BigDecimal with Oracle in Rails 1.2 RC

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lori O. (Guest)
on 2007-01-09 01:04
(Received via mailing list)
This is an example of one of several test failures I get, when using
Rails
1.2 RC2 with an Oracle database setup.

test_tubular_access(WellTest) [./test/unit/well_test.rb:37]:
<1455.0> expected but was
<#<BigDecimal:7f98584,'0.1455E4',4(12)>>.

This is the test code :

    assert_equal 1455.0, tubulars[1].shoe_depth


We don't get this problem when using MySQL as the database.

This is the third, and last, of my test errors when running rake with
Rails
1.2 RC2.

Regards, Lori
Conrad T. (Guest)
on 2007-01-09 01:48
(Received via mailing list)
Hi Lori, you cannot use decimals with assert_equal.  You'll need to
use the following:

assert_in_delta(expected_float, actual_float, delta, message="")
Passes if expected_float and actual_float are equal within delta
tolerance.

Example:

  assert_in_delta 0.05, (50000.0 / 10**6), 0.00001

Good luck,

-Conrad
Lori O. (Guest)
on 2007-01-09 02:04
(Received via mailing list)
Ok, thanks.  I was pretty sure we should not be using assert_equal
anyway (I
inherented this stuff), but it is puzzling that it worked in Rails
1.1.6,
and does not in Rails 1.2.

Regards, Lori
Michael A. Schoen (Guest)
on 2007-01-16 03:09
(Received via mailing list)
Lori O. wrote:
> Ok, thanks.  I was pretty sure we should not be using assert_equal
> anyway (I inherented this stuff), but it is puzzling that it worked in
> Rails 1.1.6, and does not in Rails 1.2.

That's because the Oracle adapater didn't support BigDecimals until
after 1.1.6 I believe -- so before you were actually just getting back
floats.
Lori O. (Guest)
on 2007-01-16 07:31
(Received via mailing list)
I guess that would explain it, then ;-)  Thanks for all your work on the
Oracle stuff, Michael!
This topic is locked and can not be replied to.