Skip to content

Commit 747b9b8

Browse files
committed
Extract locale context to a spec helper
1 parent e1d1368 commit 747b9b8

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

spec/examples/to_s_ja_spec.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
# encoding: utf-8
22
require File.dirname(__FILE__) + '/../spec_helper'
33

4-
describe IceCube::Schedule, 'to_s' do
5-
6-
before :each do
7-
I18n.locale = :ja
8-
end
9-
10-
after :all do
11-
I18n.locale = :en
12-
end
4+
describe IceCube::Schedule, 'to_s', locale: 'ja' do
135

146
it 'should represent its start time by default' do
157
t0 = Time.local(2013, 2, 14)

spec/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def Object.const_missing(sym)
5959
end
6060
end
6161

62+
config.around :each, locale: true do |example|
63+
orig_locale = I18n.locale
64+
I18n.locale = example.metadata[:locale]
65+
example.run
66+
I18n.locale = orig_locale
67+
end
68+
6269
config.around :each, expect_warnings: true do |example|
6370
capture_warnings do
6471
example.run

0 commit comments

Comments
 (0)