[rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this???
greg.hauptmann.ruby at gmail.com
Sun Jan 11 05:05:36 EST 2009
I've gone with the following ai.amount.should == BigDecimal('-323.03')
However I'm still a bit surprised that Ruby itself does allow a good "=="
test between a Float and a BigDecimal. Perhaps there's a reason that I'm
On Sun, Jan 11, 2009 at 7:23 PM, Mark Wilden <mark at mwilden.com> wrote:
> On Sun, Jan 11, 2009 at 12:17 AM, Greg Hauptmann <
> greg.hauptmann.ruby at gmail.com> wrote:
>> Any suggestions on how to write an rspec expectation for equality when you
>> get a BigDecimal back. I see that "big_decimal_variable.should == 123.23"
>> doesn't work as the ruby BigDecimal comparison (via ==) to the same Float
>> value gives false (not true as you'd expect).
> How about bd.to_s.should == 123.23.to_s ?
> rspec-users mailing list
> rspec-users at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users