Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion to/from BigDecimal doesn't work within Spork #1

Open
mstahl opened this issue Dec 19, 2013 · 2 comments
Open

Conversion to/from BigDecimal doesn't work within Spork #1

mstahl opened this issue Dec 19, 2013 · 2 comments

Comments

@mstahl
Copy link

mstahl commented Dec 19, 2013

I have been picking at this issue on and off for weeks, but hadn't been able to make any progress on it until now. I have a bunch of RSpec specs that fail only when I'm using Spork, all with the same error message for the same line of code:

Flt::DecNum can't be coerced into BigDecimal

I followed the instructions in your README just now and added a file to ./config/initializers/flt.rb with these conversion functions in it:

DecNum.context.define_conversion_from(BigDecimal) do |x, context|
  DecNum(x.to_s)
end

DecNum.context.define_conversion_to(BigDecimal) do |x|
  BigDecimal.new(x.to_s)
end

I still get the error though. The mysterious thing to me is that even before I wrote that initializer, the specs all pass without Spork. It's not like I need to use Spork (obviously I've been okay without it for several weeks), but it is pretty annoying having such an arbitrary bug. Can you lend any insight into what's happening here, why it works outside of Spork, and what I can do to fix it?

@suan
Copy link

suan commented Feb 6, 2014

I am seeing this too, but instead of only within Spork, I see it only on Linux (not on OSX) Doing an operation such as

DecNum('15.47928602931972642303350358') * BigDecimal('500.00000000000000000000')

triggers the error.

This is very similar (or equivalent) to the issue reported in the 'finance' gem.

Would appreciate any help or ideas regarding this.

@suan
Copy link

suan commented Feb 6, 2014

So, for me at least it seems like a Ruby build version problem. Upgraded from 1.9.3-p125 to 1.9.3-p194 and it went away. Worth giving a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants