# Assert\_equal fails on BigDecimal with Oracle in Rails 1.2 RC

**URL:** <https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418>\
**Category:** Rails\
**Created:** [January 9, 2007, 12:04am UTC](https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418 "2007-01-09T00:04:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lori](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8dc957/32.png) [@lori](https://www.ruby-forum.com/u/lori)\
**Post date:** [January 9, 2007, 12:04am UTC](https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418/1 "2007-01-09T00:04:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lori](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8dc957/32.png) [@lori](https://www.ruby-forum.com/u/lori)\
**Post date:** [January 9, 2007, 12:48am UTC](https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418/2 "2007-01-09T00:48:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lori](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8dc957/32.png) [@lori](https://www.ruby-forum.com/u/lori)\
**Post date:** [January 9, 2007, 1:04am UTC](https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418/3 "2007-01-09T01:04:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lori](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8dc957/32.png) [@lori](https://www.ruby-forum.com/u/lori)\
**Post date:** [January 16, 2007, 6:31am UTC](https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418/4 "2007-01-16T06:31:12Z")

</div>

I guess that would explain it, then 😉 Thanks for all your work on the  
Oracle stuff, Michael!

---

<div class="post-metadata">

**Author:** ![lori](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8dc957/32.png) [@lori](https://www.ruby-forum.com/u/lori)\
**Post date:** [January 16, 2007, 2:09am UTC](https://www.ruby-forum.com/t/assert-equal-fails-on-bigdecimal-with-oracle-in-rails-1-2-rc/81418/5 "2007-01-16T02:09:41Z")

</div>

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.
