Search code examples
ruby-on-railsrubyrspecbigdecimal

How to read BigDecimal format in RSpec?


After running my RSpec tests I frequently get output like this:

expected: 50
     got: #<BigDecimal:7fbdcd1b5408,'0.22E3',9(36)>

How can I find out what number RSpec actually got?

Thanks for any help.


Solution

  • As @jcm commented, It's 220. (= 0.22 * 103)

    require 'bigdecimal'
    BigDecimal.new(220) # => #<BigDecimal:3037368,'0.22E3',9(36)>
    BigDecimal.new(220) == 220 # => true