Skip to content

Commit aeb1f19

Browse files
committed
set default_currency before every test and simplify tests
1 parent 12c79f4 commit aeb1f19

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

spec/money_spec.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,9 @@
7272
end
7373

7474
context 'without a default' do
75-
around do |example|
76-
default_currency = Money.default_currency
75+
it 'should throw an NoCurrency Error' do
7776
Money.default_currency = nil
7877

79-
example.run
80-
81-
Money.default_currency = default_currency
82-
end
83-
84-
it 'should throw an NoCurrency Error' do
8578
expect { money }.to raise_error(Money::Currency::NoCurrency)
8679
end
8780
end
@@ -1018,9 +1011,6 @@ def m.amount
10181011
end
10191012

10201013
describe ".default_currency" do
1021-
before { Money.setup_defaults }
1022-
after { Money.setup_defaults }
1023-
10241014
it "accepts a lambda" do
10251015
Money.default_currency = lambda { :eur }
10261016
expect(Money.default_currency).to eq Money::Currency.new(:eur)
@@ -1061,8 +1051,6 @@ def m.amount
10611051
end
10621052

10631053
describe '.default_bank' do
1064-
after { Money.setup_defaults }
1065-
10661054
it 'accepts a bank instance' do
10671055
Money.default_bank = Money::Bank::SingleCurrency.instance
10681056
expect(Money.default_bank).to be_instance_of(Money::Bank::SingleCurrency)

spec/spec_helper.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@
113113
# as the one that triggered the failure.
114114
Kernel.srand config.seed
115115

116-
# Code to run once before the entire test suite
117-
config.before(:suite) do
116+
config.before(:each) do
118117
Money.default_currency = Money::Currency.new("USD")
119118
end
120119
end

0 commit comments

Comments
 (0)