Skip to content

Commit 63ad350

Browse files
committed
Clean up spec and reset available locales to :en in after block
1 parent 7ee0007 commit 63ad350

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

spec/grape/exceptions/base_spec.rb

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,25 @@
77
let(:key) { :invalid_formatter }
88
let(:attributes) { { klass: String, to_format: 'xml' } }
99

10+
before { I18n.default_locale = :de }
11+
after do
12+
I18n.available_locales = %i[en]
13+
I18n.enforce_available_locales = false
14+
end
15+
1016
context 'when I18n enforces available locales' do
1117
before { I18n.enforce_available_locales = true }
12-
after do
13-
I18n.available_locales = %i[de en]
14-
I18n.enforce_available_locales = false
15-
end
1618

1719
context 'when the fallback locale is available' do
18-
before do
19-
I18n.available_locales = %i[de en]
20-
I18n.default_locale = :de
21-
end
20+
before { I18n.available_locales = %i[de en] }
2221

2322
it 'returns the translated message' do
2423
expect(subject).to eq('cannot convert String to xml')
2524
end
2625
end
2726

2827
context 'when the fallback locale is not available' do
29-
before do
30-
I18n.available_locales = %i[de jp]
31-
I18n.default_locale = :de
32-
end
28+
before { I18n.available_locales = %i[de jp] }
3329

3430
it 'returns the translation string' do
3531
expect(subject).to eq("grape.errors.messages.#{key}")
@@ -39,24 +35,17 @@
3935

4036
context 'when I18n does not enforce available locales' do
4137
before { I18n.enforce_available_locales = false }
42-
after { I18n.available_locales = %i[de en] }
4338

4439
context 'when the fallback locale is available' do
45-
before do
46-
I18n.available_locales = %i[de en]
47-
I18n.default_locale = :de
48-
end
40+
before { I18n.available_locales = %i[de en] }
4941

5042
it 'returns the translated message' do
5143
expect(subject).to eq('cannot convert String to xml')
5244
end
5345
end
5446

5547
context 'when the fallback locale is not available' do
56-
before do
57-
I18n.available_locales = %i[de jp]
58-
I18n.default_locale = :de
59-
end
48+
before { I18n.available_locales = %i[de jp] }
6049

6150
it 'returns the translated message' do
6251
expect(subject).to eq('cannot convert String to xml')

0 commit comments

Comments
 (0)