avadev / AvaTax-REST-V2-Ruby-SDK

Sales Tax API SDK for Ruby and AvaTax REST
https://developer.avalara.com/sdk/
Apache License 2.0
36 stars 56 forks source link

Ruby 2.2+ vs BigDecimal #16

Closed tubbo closed 6 years ago

tubbo commented 6 years ago

After updating to avatax v17.12 we noticed tests failing that made use of JSON and BigDecimal, like so:

Failure:
Search::ProductSearchTest#test_facets [test/queries/search/product_search_test.rb:77]:
--- expected
+++ actual
@@ -1 +1 @@
-{{:to=>5.0}=>1, {:from=>5.0, :to=>9.99}=>2, {:from=>10.0}=>1}
+{{:to=>0.5e1}=>1, {:from=>0.5e1, :to=>0.999e1}=>2, {:from=>0.1e2}=>1}

(29 more lines...)

It seems to stem from this gem's use of the Oj library and this configuration that's applied when you call the AvaTax::API#connection method. Our solution was to just pull that configuration out, and everything worked as expected. But I was curious as to why it's included in the first place? Is it safe to do some kind of conditional check to make sure we're not in Ruby v2.2+ before applying this config?