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

Tero Tilus tero at tilus.net
Sun Jan 11 16:31:20 EST 2009

2009-01-11 18:17, Greg Hauptmann:
> 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"

If you register keywords "comparison" and "float", you should train
yourself to cry out "delta" without even thinking.  ;)

Would this work for you?

  big_decimal_variable.should be_close(123.23, 0.005)

Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/

More information about the rspec-users mailing list