Hi, 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). For background / as an example see below:
?> bd => #<BigDecimal:221832c,'-0.32303E3',8(12)> >> f => -323.03 >> f.class => Float >> bd.should == f Spec::Expectations::ExpectationNotMetError: expected: -323.03, got: #<BigDecimal:221832c,'-0.32303E3',8(12)> (using ==) from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/expectations.rb:52:in `fail_with' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:46:in `fail_with_message' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:61:in `__delegate_method_missing_to_given' from /opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb:12:in `==' from (irb):73 >> bd == f => false >> f == bd => false thanks Greg
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users