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.
11ba36dcbe955d1f2c4111de906134c4?d=identicon&s=25 Lori Olson (Guest)
on 2007-01-09 00: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
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2007-01-09 00: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
11ba36dcbe955d1f2c4111de906134c4?d=identicon&s=25 Lori Olson (Guest)
on 2007-01-09 01: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
E75cda3e915fa209386fae3de962cb6a?d=identicon&s=25 Michael A. Schoen (Guest)
on 2007-01-16 02:09
(Received via mailing list)
Lori Olson 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.
11ba36dcbe955d1f2c4111de906134c4?d=identicon&s=25 Lori Olson (Guest)
on 2007-01-16 06: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.