Skip to content

Commit 36551e2

Browse files
committed
Set I18n to enforce available locales as a default in spec helper
1 parent 63ad350 commit 36551e2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

spec/grape/exceptions/base_spec.rb

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

10-
before { I18n.default_locale = :de }
1110
after do
1211
I18n.available_locales = %i[en]
13-
I18n.enforce_available_locales = false
12+
I18n.default_locale = :en
1413
end
1514

1615
context 'when I18n enforces available locales' do
1716
before { I18n.enforce_available_locales = true }
1817

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

2224
it 'returns the translated message' do
2325
expect(subject).to eq('cannot convert String to xml')
2426
end
2527
end
2628

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

3035
it 'returns the translation string' do
3136
expect(subject).to eq("grape.errors.messages.#{key}")

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
require file
1313
end
1414

15-
I18n.enforce_available_locales = false
15+
I18n.enforce_available_locales = true
1616

1717
RSpec.configure do |config|
1818
config.include Rack::Test::Methods

0 commit comments

Comments
 (0)