Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
inherit_from: .rubocop_todo.yml

plugins:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gem "rake"

# Linting
gem "rubocop", require: false
gem "rubocop-performance", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false

Expand Down
10 changes: 5 additions & 5 deletions spec/money/allocation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
BigDecimal("33.3333333333"),
],
)
expect(parts.inject(0, :+)).to eq(amount)
expect(parts.sum).to eq(amount)
end
end
end
Expand Down Expand Up @@ -132,7 +132,7 @@
BigDecimal("33.3333333333"),
],
)
expect(parts.inject(0, :+)).to eq(amount)
expect(parts.sum).to eq(amount)
end
end
end
Expand All @@ -156,7 +156,7 @@
]

result = described_class.generate(amount, allocations)
expect(result.reduce(&:+)).to eq(amount)
expect(result.sum).to eq(amount)
expect(result).to eq(
[
61566,
Expand Down Expand Up @@ -193,7 +193,7 @@
]

result = described_class.generate(amount, allocations)
expect(result.reduce(&:+)).to eq(amount)
expect(result.sum).to eq(amount)
expect(result).to eq(
[
-61566,
Expand Down Expand Up @@ -229,7 +229,7 @@

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

expected = %w[
6.3347130857200688 6.3347130857200689 6.3347130857200688 6.3347130857200688
Expand Down
2 changes: 1 addition & 1 deletion spec/money/currency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def to_s

it "is thread safe" do
ids = []
2.times.map { Thread.new { ids << described_class.new("USD").object_id } }.each(&:join)
Array.new(2) { Thread.new { ids << described_class.new("USD").object_id } }.each(&:join)
expect(ids.uniq.length).to eq(1)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/money/rates_store/memory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
end

describe "#transaction" do
let(:guard) { store.instance_variable_get("@guard") }
let(:guard) { store.instance_variable_get(:@guard) }

before do
allow(guard).to receive(:synchronize)
Expand Down
6 changes: 3 additions & 3 deletions spec/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@
end

it "does not round rationals" do
splits = 7.times.map { Rational(950, 6650) }
splits = Array.new(7) { Rational(950, 6650) }
moneys = Money.us_dollar(6650).allocate(splits)
moneys.each do |money|
expect(money.cents).to eq 950
Expand Down Expand Up @@ -937,7 +937,7 @@
context "with infinite_precision", :default_infinite_precision_true do
it "allows for fractional cents allocation" do
moneys = Money.new(100).allocate([1, 1, 1])
expect(moneys.inject(0, :+)).to eq(Money.new(100))
expect(moneys.sum).to eq(Money.new(100))
end
end
end
Expand Down Expand Up @@ -975,7 +975,7 @@
context "with infinite_precision", :default_infinite_precision_true do
it "allows for splitting by fractional cents" do
moneys = Money.new(100).split(3)
expect(moneys.inject(0, :+)).to eq(Money.new(100))
expect(moneys.sum).to eq(Money.new(100))
end
end
end
Expand Down