Skip to content

Commit 9ee6385

Browse files
committed
Lint: Fix Performance/Sum
1 parent 0a67836 commit 9ee6385

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/money/allocation_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
BigDecimal("33.3333333333"),
5757
],
5858
)
59-
expect(parts.inject(0, :+)).to eq(amount)
59+
expect(parts.sum).to eq(amount)
6060
end
6161
end
6262
end
@@ -132,7 +132,7 @@
132132
BigDecimal("33.3333333333"),
133133
],
134134
)
135-
expect(parts.inject(0, :+)).to eq(amount)
135+
expect(parts.sum).to eq(amount)
136136
end
137137
end
138138
end
@@ -156,7 +156,7 @@
156156
]
157157

158158
result = described_class.generate(amount, allocations)
159-
expect(result.reduce(&:+)).to eq(amount)
159+
expect(result.sum).to eq(amount)
160160
expect(result).to eq(
161161
[
162162
61566,
@@ -193,7 +193,7 @@
193193
]
194194

195195
result = described_class.generate(amount, allocations)
196-
expect(result.reduce(&:+)).to eq(amount)
196+
expect(result.sum).to eq(amount)
197197
expect(result).to eq(
198198
[
199199
-61566,
@@ -229,7 +229,7 @@
229229

230230
it "allocates with required precision" do
231231
result = described_class.generate(amount, allocations, 16)
232-
expect(result.reduce(&:+)).to eq(amount)
232+
expect(result.sum).to eq(amount)
233233

234234
expected = %w[
235235
6.3347130857200688 6.3347130857200689 6.3347130857200688 6.3347130857200688

spec/money_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@
937937
context "with infinite_precision", :default_infinite_precision_true do
938938
it "allows for fractional cents allocation" do
939939
moneys = Money.new(100).allocate([1, 1, 1])
940-
expect(moneys.inject(0, :+)).to eq(Money.new(100))
940+
expect(moneys.sum).to eq(Money.new(100))
941941
end
942942
end
943943
end
@@ -975,7 +975,7 @@
975975
context "with infinite_precision", :default_infinite_precision_true do
976976
it "allows for splitting by fractional cents" do
977977
moneys = Money.new(100).split(3)
978-
expect(moneys.inject(0, :+)).to eq(Money.new(100))
978+
expect(moneys.sum).to eq(Money.new(100))
979979
end
980980
end
981981
end

0 commit comments

Comments
 (0)