Skip to content

Commit

Permalink
Merge pull request #62 from rmacklin/fix-BigDecimal-deprecation
Browse files Browse the repository at this point in the history
Replace deprecated BigDecimal.new() calls with BigDecimal()
  • Loading branch information
lostapathy authored Feb 12, 2019
2 parents a4b00d9 + 7fceacc commit 0d6fd8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
psych (3.0.0)
psych (3.1.0)
public_suffix (3.0.1)
rack (1.6.8)
rake (0.9.6)
Expand Down
2 changes: 1 addition & 1 deletion lib/roxml/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def self.block_shorthands
CORE_BLOCK_SHORTHANDS.tap do |blocks|
blocks.reverse_merge!(BigDecimal => lambda do |val|
all(val) do |v|
BigDecimal.new(v) unless v.blank?
BigDecimal(v) unless v.blank?
end
end) if defined?(BigDecimal)

Expand Down
8 changes: 4 additions & 4 deletions spec/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ def self.from_xml(val)
it_should_behave_like "block shorthand type declaration"

it "should translate text to decimal numbers" do
expect(@definition.blocks.first['3']).to eq(BigDecimal.new("3.0"))
expect(@definition.blocks.first['0.3']).to eq(BigDecimal.new("0.3"))
expect(@definition.blocks.first['3']).to eq(BigDecimal("3.0"))
expect(@definition.blocks.first['0.3']).to eq(BigDecimal("0.3"))
end

# Ruby behavior of BigDecimal changed in 2.4, this test is not valid on older rubies
Expand All @@ -293,12 +293,12 @@ def self.from_xml(val)
end

it "should extract what it can" do
expect(@definition.blocks.first['11sttf']).to eql(BigDecimal.new("11.0"))
expect(@definition.blocks.first['11sttf']).to eql(BigDecimal("11.0"))
end

context "when passed an array" do
it "should translate the array elements to integer" do
expect(@definition.blocks.first.call(["12.1", "328.2"])).to eq([BigDecimal.new("12.1"), BigDecimal.new("328.2")])
expect(@definition.blocks.first.call(["12.1", "328.2"])).to eq([BigDecimal("12.1"), BigDecimal("328.2")])
end
end
end
Expand Down

0 comments on commit 0d6fd8e

Please sign in to comment.