Lori Olson
2007-Jan-08 23:02 UTC
assert_equal fails on BigDecimal with Oracle in Rails 1.2 RC2
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2007-Jan-08 23:42 UTC
Re: assert_equal fails on BigDecimal with Oracle in Rails 1.2 RC2
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 On 1/8/07, Lori Olson <javadragon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lori Olson
2007-Jan-09 00:03 UTC
Re: assert_equal fails on BigDecimal with Oracle in Rails 1.2 RC2
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 On 1/8/07, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > 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 > > On 1/8/07, Lori Olson <javadragon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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 > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael A. Schoen
2007-Jan-16 01:09 UTC
Re: assert_equal fails on BigDecimal with Oracle in Rails 1.2 RC2
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Lori Olson
2007-Jan-16 05:30 UTC
Re: assert_equal fails on BigDecimal with Oracle in Rails 1.2 RC2
I guess that would explain it, then ;-) Thanks for all your work on the Oracle stuff, Michael! On 1/15/07, Michael A. Schoen <schoenm-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> > > 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. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---