This causes a problem i.e. while matching in RSpec change method
TruffleRuby 1.0.0 RC15 (wrong)
BigDecimal('1.2920').hash
# => 716996660
BigDecimal('1.2920').hash
# => 1195473402
MRI 2.6.2 (correct)
BigDecimal('1.2920').hash
# => 615576019346831331
BigDecimal('1.2920').hash
# => 615576019346831331
This is a real case in my specs when I'm testing if an import of exchange rates is idempotent. Due the above issue it fails though.
expect { service.call }.not_to change { DB[:exchange_rates].select(:rate).all }
@nirvdrum Is this an easy fix?
@deepj Sorry for just getting to this. You pinged me while I was traveling and I just missed it. I'm working on a fix now. It's pretty straightforward. The problem is we're currently hashing BigDecimal objects as if they're arbitrary object references. We need to treat them like value types.
This issue has been fixed as of 3b887a14ccbaad4e38f95a012c03da4b0b1843d8. We didn't customize the hash method for BigDecimal, so it was falling back to the default, which just tries to assign an identifier to each object with good hash distribution. The fix should appear in our next release.