Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 522
Tintin81 Avatar asked Oct 06 '13 11:10

Tintin81


1 Answers

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
like image 191
falsetru Avatar answered Sep 22 '22 11:09

falsetru