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
14 changes: 0 additions & 14 deletions .rubocop_todo.yml

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

12 changes: 6 additions & 6 deletions spec/bank/variable_exchange_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,30 @@
end

describe "#export_rates" do
let(:expected_rates) { { "USD_TO_EUR" => 1.25, "USD_TO_JPY" => 2.55 } }

before do
bank.set_rate('USD', 'EUR', 1.25)
bank.set_rate('USD', 'JPY', 2.55)

@rates = { "USD_TO_EUR" => 1.25, "USD_TO_JPY" => 2.55 }
end

context "with format == :json" do
it "returns rates formatted as json" do
json = bank.export_rates(:json)
expect(JSON.load(json)).to eq @rates
expect(JSON.load(json)).to eq expected_rates
end
end

context "with format == :ruby" do
it "returns rates formatted as ruby objects" do
expect(Marshal.load(bank.export_rates(:ruby))).to eq @rates
expect(Marshal.load(bank.export_rates(:ruby))).to eq expected_rates
end
end

context "with format == :yaml" do
it "returns rates formatted as yaml" do
yaml = bank.export_rates(:yaml)
expect(YAML.load(yaml)).to eq @rates
expect(YAML.load(yaml)).to eq expected_rates
end
end

Expand All @@ -206,7 +206,7 @@

bank.export_rates(:json, 'null')

expect(f).to have_received(:write).with(JSON.dump(@rates))
expect(f).to have_received(:write).with(JSON.dump(expected_rates))
end
end

Expand Down
14 changes: 8 additions & 6 deletions spec/money/arithmetic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@

context 'when conversions disallowed' do
before do
@old_default_bank = Money.default_bank
Money.disallow_currency_conversion!
end

after do
Money.default_bank = @old_default_bank
around do |example|
previous_bank = Money.default_bank
example.call
Money.default_bank = previous_bank
end

context 'when currencies differ' do
Expand Down Expand Up @@ -858,12 +859,13 @@

context 'when conversions disallowed' do
before do
@old_default_bank = Money.default_bank
Money.disallow_currency_conversion!
end

after do
Money.default_bank = @old_default_bank
around do |example|
previous_bank = Money.default_bank
example.call
Money.default_bank = previous_bank
end

context 'when other is money with different currency' do
Expand Down
9 changes: 6 additions & 3 deletions spec/money/formatting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@
end

context "when in Japanese" do
before { @_locale = I18n.locale; I18n.locale = :ja }

after { I18n.locale = @_locale }
around do |example|
previous_locale = I18n.locale
I18n.locale = :ja
example.call
I18n.locale = previous_locale
end

it "formats Japanese currency properly" do
money = Money.new(1000, "JPY")
Expand Down
20 changes: 9 additions & 11 deletions spec/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@
end

describe ".add_rate" do
before do
@default_bank = Money.default_bank
around do |example|
previous_bank = Money.default_bank
Money.default_bank = Money::Bank::VariableExchange.new
end

after do
Money.default_bank = @default_bank
example.call

Money.default_bank = previous_bank
end

it "saves rate into current bank" do
Expand All @@ -170,12 +170,10 @@
end

describe ".disallow_currency_conversions!" do
before do
@default_bank = Money.default_bank
end

after do
Money.default_bank = @default_bank
around do |example|
default_bank = Money.default_bank
example.call
Money.default_bank = default_bank
end

it "disallows conversions when doing money arithmetic" do
Expand Down
Loading