[rspec-users] Why can not a BigDecimal be compared to a Float via "==". How should I handle this???

Mark Wilden mark at mwilden.com
Sun Jan 11 17:06:42 EST 2009


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).
>

Noting there are two decimal places in your data, I might suggest using the
Money plugin.

///ark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090111/1d9b0159/attachment.html>


More information about the rspec-users mailing list