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
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ RSpec/DescribedClass:
- 'spec/money_spec.rb'
- 'spec/money/formatting_spec.rb'

RSpec/IdenticalEqualityAssertion:
# Allow identical expressions on both sides of the equality since we are
# testing defining equality.
Enabled: false

RSpec/MultipleExpectations:
# Do not limit the amount of expectations in a spec
Enabled: false
Expand Down
11 changes: 0 additions & 11 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions spec/currency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,6 @@ def to_s
describe "#inspect" do
it "works as documented" do
expect(described_class.new(:usd).inspect).to eq "#<Money::Currency id: usd, priority: 1, symbol_first: true, thousands_separator: ,, html_entity: $, decimal_mark: ., name: United States Dollar, symbol: $, subunit_to_unit: 100, exponent: 2, iso_code: USD, iso_numeric: 840, subunit: Cent, smallest_denomination: 1, format: >"
end

it "works as documented" do
expect(described_class.new(:aed).inspect).to eq "#<Money::Currency id: aed, priority: 100, symbol_first: false, thousands_separator: ,, html_entity: , decimal_mark: ., name: United Arab Emirates Dirham, symbol: د.إ, subunit_to_unit: 100, exponent: 2, iso_code: AED, iso_numeric: 784, subunit: Fils, smallest_denomination: 25, format: %n %u>"
end
end
Expand Down
20 changes: 10 additions & 10 deletions spec/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -856,17 +856,11 @@

describe "#allocate" do
it "takes no action when one gets all" do
expect(Money.us_dollar(005).allocate([1.0])).to eq [Money.us_dollar(5)]
expect(Money.us_dollar(5).allocate([1.0])).to eq [Money.us_dollar(5)]
end

it "keeps currencies intact" do
expect(Money.ca_dollar(005).allocate([1])).to eq [Money.ca_dollar(5)]
end

it "does not lose pennies" do
moneys = Money.us_dollar(5).allocate([0.3, 0.7])
expect(moneys[0]).to eq Money.us_dollar(2)
expect(moneys[1]).to eq Money.us_dollar(3)
expect(Money.ca_dollar(5).allocate([1])).to eq [Money.ca_dollar(5)]
end

it "handles small splits" do
Expand All @@ -881,8 +875,14 @@
expect(moneys[1]).to eq Money.us_dollar(3)
end

it "does not lose pennies" do
moneys = Money.us_dollar(100).allocate([0.333, 0.333, 0.333])
it "does not lose pennies for one decimal" do
moneys = Money.us_dollar(5).allocate([0.3, 0.7])
expect(moneys[0]).to eq Money.us_dollar(2)
expect(moneys[1]).to eq Money.us_dollar(3)
end

it "does not lose pennies for three decimals" do
moneys = Money.us_dollar(1_00).allocate([0.333, 0.333, 0.333])
expect(moneys[0].cents).to eq 34
expect(moneys[1].cents).to eq 33
expect(moneys[2].cents).to eq 33
Expand Down