r18n-core 1.1.11 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +4 -0
  3. data/README.md +2 -2
  4. data/lib/r18n-core/filter_list.rb +2 -3
  5. data/lib/r18n-core/filters.rb +9 -10
  6. data/lib/r18n-core/helpers.rb +0 -1
  7. data/lib/r18n-core/i18n.rb +1 -2
  8. data/lib/r18n-core/locale.rb +10 -12
  9. data/lib/r18n-core/translated.rb +3 -4
  10. data/lib/r18n-core/translated_string.rb +0 -1
  11. data/lib/r18n-core/translation.rb +2 -3
  12. data/lib/r18n-core/unsupported_locale.rb +0 -1
  13. data/lib/r18n-core/untranslated.rb +0 -1
  14. data/lib/r18n-core/utils.rb +0 -11
  15. data/lib/r18n-core/version.rb +1 -2
  16. data/lib/r18n-core/yaml_loader.rb +0 -1
  17. data/lib/r18n-core/yaml_methods.rb +2 -8
  18. data/lib/r18n-core.rb +0 -3
  19. data/locales/bg.rb +11 -13
  20. data/locales/ca.rb +13 -14
  21. data/locales/cs.rb +15 -16
  22. data/locales/da.rb +13 -15
  23. data/locales/de.rb +14 -15
  24. data/locales/en-au.rb +2 -2
  25. data/locales/en-gb.rb +2 -2
  26. data/locales/en-us.rb +5 -7
  27. data/locales/en.rb +14 -14
  28. data/locales/eo.rb +11 -12
  29. data/locales/es-us.rb +6 -8
  30. data/locales/es.rb +11 -12
  31. data/locales/fi.rb +16 -17
  32. data/locales/fr.rb +10 -11
  33. data/locales/gl.rb +12 -13
  34. data/locales/hr.rb +12 -13
  35. data/locales/hu.rb +12 -13
  36. data/locales/id.rb +9 -9
  37. data/locales/it.rb +9 -10
  38. data/locales/ja.rb +11 -12
  39. data/locales/kk.rb +16 -18
  40. data/locales/lv.rb +16 -17
  41. data/locales/mn.rb +12 -14
  42. data/locales/nb.rb +12 -13
  43. data/locales/nl.rb +13 -14
  44. data/locales/no.rb +12 -13
  45. data/locales/pl.rb +13 -14
  46. data/locales/pt-br.rb +2 -3
  47. data/locales/pt.rb +13 -14
  48. data/locales/ru.rb +14 -15
  49. data/locales/sk.rb +15 -16
  50. data/locales/sr-latn.rb +12 -14
  51. data/locales/sv-se.rb +11 -13
  52. data/locales/th.rb +13 -14
  53. data/locales/tr.rb +12 -15
  54. data/locales/uk.rb +11 -15
  55. data/locales/zh-cn.rb +2 -3
  56. data/locales/zh-tw.rb +5 -6
  57. data/locales/zh.rb +10 -11
  58. data/r18n-core.gemspec +5 -4
  59. data/spec/filters_spec.rb +94 -91
  60. data/spec/i18n_spec.rb +66 -68
  61. data/spec/locale_spec.rb +74 -74
  62. data/spec/locales/cs_spec.rb +14 -14
  63. data/spec/locales/en-us_spec.rb +6 -6
  64. data/spec/locales/en_spec.rb +6 -6
  65. data/spec/locales/fr_spec.rb +2 -2
  66. data/spec/locales/hu_spec.rb +6 -7
  67. data/spec/locales/it_spec.rb +3 -4
  68. data/spec/locales/pl_spec.rb +14 -14
  69. data/spec/locales/ru_spec.rb +13 -13
  70. data/spec/locales/sk_spec.rb +14 -14
  71. data/spec/locales/th_spec.rb +2 -2
  72. data/spec/r18n_spec.rb +47 -49
  73. data/spec/spec_helper.rb +0 -7
  74. data/spec/translated_spec.rb +26 -28
  75. data/spec/translation_spec.rb +38 -40
  76. data/spec/yaml_loader_spec.rb +14 -16
  77. metadata +2 -2
data/spec/i18n_spec.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
3
  describe R18n::I18n do
@@ -13,31 +12,31 @@ describe R18n::I18n do
13
12
  end
14
13
 
15
14
  it "parses HTTP_ACCEPT_LANGUAGE" do
16
- R18n::I18n.parse_http(nil).should == []
17
- R18n::I18n.parse_http('').should == []
18
- R18n::I18n.parse_http('ru,en;q=0.9').should == ['ru', 'en']
19
- R18n::I18n.parse_http('ru;q=0.8,en;q=0.9').should == ['en', 'ru']
15
+ expect(R18n::I18n.parse_http(nil)).to eq([])
16
+ expect(R18n::I18n.parse_http('')).to eq([])
17
+ expect(R18n::I18n.parse_http('ru,en;q=0.9')).to eq(['ru', 'en'])
18
+ expect(R18n::I18n.parse_http('ru;q=0.8,en;q=0.9')).to eq(['en', 'ru'])
20
19
  end
21
20
 
22
21
  it "has default locale" do
23
22
  R18n::I18n.default = 'ru'
24
- R18n::I18n.default.should == 'ru'
23
+ expect(R18n::I18n.default).to eq('ru')
25
24
  end
26
25
 
27
26
  it "loads locales" do
28
27
  i18n = R18n::I18n.new('en', DIR)
29
- i18n.locales.should == [R18n.locale('en')]
28
+ expect(i18n.locales).to eq([R18n.locale('en')])
30
29
 
31
30
  i18n = R18n::I18n.new(['ru', 'nolocale-DL'], DIR)
32
- i18n.locales.should == [R18n.locale('ru'),
31
+ expect(i18n.locales).to eq([R18n.locale('ru'),
33
32
  R18n::UnsupportedLocale.new('nolocale-DL'),
34
33
  R18n::UnsupportedLocale.new('nolocale'),
35
- R18n.locale('en')]
34
+ R18n.locale('en')])
36
35
  end
37
36
 
38
37
  it "returns translations loaders" do
39
38
  i18n = R18n::I18n.new('en', DIR)
40
- i18n.translation_places.should == [R18n::Loader::YAML.new(DIR)]
39
+ expect(i18n.translation_places).to eq([R18n::Loader::YAML.new(DIR)])
41
40
  end
42
41
 
43
42
  it "loads translations by loader" do
@@ -45,7 +44,7 @@ describe R18n::I18n do
45
44
  def available; [R18n.locale('en')]; end
46
45
  def load(locale); { 'custom' => 'Custom' }; end
47
46
  end
48
- R18n::I18n.new('en', loader.new).custom.should == 'Custom'
47
+ expect(R18n::I18n.new('en', loader.new).custom).to eq('Custom')
49
48
  end
50
49
 
51
50
  it "passes parameters to default loader" do
@@ -55,129 +54,129 @@ describe R18n::I18n do
55
54
  def load(locale); { 'custom' => @param }; end
56
55
  end
57
56
  R18n.default_loader = loader
58
- R18n::I18n.new('en', 'default').custom.should == 'default'
57
+ expect(R18n::I18n.new('en', 'default').custom).to eq('default')
59
58
  end
60
59
 
61
60
  it "loads translations" do
62
61
  i18n = R18n::I18n.new(['ru', 'en'], DIR)
63
- i18n.one.should == 'Один'
64
- i18n[:one].should == 'Один'
65
- i18n['one'].should == 'Один'
66
- i18n.only.english.should == 'Only in English'
62
+ expect(i18n.one).to eq('Один')
63
+ expect(i18n[:one]).to eq('Один')
64
+ expect(i18n['one']).to eq('Один')
65
+ expect(i18n.only.english).to eq('Only in English')
67
66
  end
68
67
 
69
68
  it "loads translations from several dirs" do
70
69
  i18n = R18n::I18n.new(['nolocale', 'en'], [TWO, DIR])
71
- i18n.in.two.should == 'Two'
72
- i18n.in.another.level.should == 'Hierarchical'
70
+ expect(i18n.in.two).to eq('Two')
71
+ expect(i18n.in.another.level).to eq('Hierarchical')
73
72
  end
74
73
 
75
74
  it "uses extension places" do
76
75
  R18n.extension_places << EXT
77
76
 
78
77
  i18n = R18n::I18n.new('en', DIR)
79
- i18n.ext.should == 'Extension'
80
- i18n.one.should == 'One'
78
+ expect(i18n.ext).to eq('Extension')
79
+ expect(i18n.one).to eq('One')
81
80
  end
82
81
 
83
82
  it "doesn't use extension without app translations with same locale" do
84
83
  R18n.extension_places << EXT
85
84
 
86
85
  i18n = R18n::I18n.new(['notransl', 'en'], DIR)
87
- i18n.ext.should == 'Extension'
86
+ expect(i18n.ext).to eq('Extension')
88
87
  end
89
88
 
90
89
  it "ignores case on loading" do
91
90
  i18n = R18n::I18n.new('nolocale', [DIR])
92
- i18n.one.should == 'ONE'
91
+ expect(i18n.one).to eq('ONE')
93
92
 
94
93
  i18n = R18n::I18n.new('nolocale', [DIR])
95
- i18n.one.should == 'ONE'
94
+ expect(i18n.one).to eq('ONE')
96
95
  end
97
96
 
98
97
  it "loads default translation" do
99
98
  i18n = R18n::I18n.new('nolocale', DIR)
100
- i18n.one.should == 'ONE'
101
- i18n.two.should == 'Two'
99
+ expect(i18n.one).to eq('ONE')
100
+ expect(i18n.two).to eq('Two')
102
101
  end
103
102
 
104
103
  it "loads sublocales for first locale" do
105
104
  R18n::I18n.default = 'notransl'
106
105
 
107
106
  i18n = R18n::I18n.new('ru', DIR)
108
- i18n.one.should == 'Один'
109
- i18n.two.should == 'Two'
107
+ expect(i18n.one).to eq('Один')
108
+ expect(i18n.two).to eq('Two')
110
109
  end
111
110
 
112
111
  it "returns available translations" do
113
112
  i18n = R18n::I18n.new('en', DIR)
114
- i18n.available_locales.should =~ [R18n.locale('nolocale'),
113
+ expect(i18n.available_locales).to match_array([R18n.locale('nolocale'),
115
114
  R18n.locale('ru'),
116
- R18n.locale('en')]
115
+ R18n.locale('en')])
117
116
  end
118
117
 
119
118
  it "caches translations" do
120
119
  counter = CounterLoader.new('en')
121
120
 
122
121
  R18n::I18n.new('en', counter)
123
- counter.loaded.should == 1
122
+ expect(counter.loaded).to eq(1)
124
123
 
125
124
  R18n::I18n.new('en', counter)
126
- counter.loaded.should == 1
125
+ expect(counter.loaded).to eq(1)
127
126
 
128
127
  R18n.clear_cache!
129
128
  R18n::I18n.new('en', counter)
130
- counter.loaded.should == 2
129
+ expect(counter.loaded).to eq(2)
131
130
  end
132
131
 
133
132
  it "doesn't clear cache when custom filters are specified" do
134
133
  counter = CounterLoader.new('en')
135
134
 
136
- R18n::I18n.new('en', counter, :off_filters => :untranslated,
137
- :on_filters => :untranslated_html)
138
- counter.loaded.should == 1
135
+ R18n::I18n.new('en', counter,
136
+ off_filters: :untranslated, on_filters: :untranslated_html)
137
+ expect(counter.loaded).to eq(1)
139
138
 
140
- R18n::I18n.new('en', counter, :off_filters => :untranslated,
141
- :on_filters => :untranslated_html)
142
- counter.loaded.should == 1
139
+ R18n::I18n.new('en', counter,
140
+ off_filters: :untranslated, on_filters: :untranslated_html)
141
+ expect(counter.loaded).to eq(1)
143
142
  end
144
143
 
145
144
  it "caches translations by used locales" do
146
145
  counter = CounterLoader.new('en', 'ru')
147
146
 
148
147
  R18n::I18n.new('en', counter)
149
- counter.loaded.should == 1
148
+ expect(counter.loaded).to eq(1)
150
149
 
151
150
  R18n::I18n.new(['en', 'fr'], counter)
152
- counter.loaded.should == 1
151
+ expect(counter.loaded).to eq(1)
153
152
 
154
153
  R18n::I18n.new(['en', 'ru'], counter)
155
- counter.loaded.should == 3
154
+ expect(counter.loaded).to eq(3)
156
155
 
157
156
  R18n::I18n.new(['ru', 'en'], counter)
158
- counter.loaded.should == 5
157
+ expect(counter.loaded).to eq(5)
159
158
  end
160
159
 
161
160
  it "caches translations by places" do
162
161
  counter = CounterLoader.new('en', 'ru')
163
162
 
164
163
  R18n::I18n.new('en', counter)
165
- counter.loaded.should == 1
164
+ expect(counter.loaded).to eq(1)
166
165
 
167
166
  R18n::I18n.new('en', [counter, DIR])
168
- counter.loaded.should == 2
167
+ expect(counter.loaded).to eq(2)
169
168
 
170
169
  R18n.extension_places << EXT
171
170
  R18n::I18n.new('en', counter)
172
- counter.loaded.should == 3
171
+ expect(counter.loaded).to eq(3)
173
172
 
174
173
  same = CounterLoader.new('en', 'ru')
175
174
  R18n::I18n.new('en', same)
176
- same.loaded.should == 0
175
+ expect(same.loaded).to eq(0)
177
176
 
178
177
  different = CounterLoader.new('en', 'fr')
179
178
  R18n::I18n.new('en', different)
180
- different.loaded.should == 1
179
+ expect(different.loaded).to eq(1)
181
180
  end
182
181
 
183
182
  it "reloads translations" do
@@ -191,50 +190,49 @@ describe R18n::I18n do
191
190
  end
192
191
 
193
192
  i18n = R18n::I18n.new('en', loader.new)
194
- i18n.one.should == 1
193
+ expect(i18n.one).to eq(1)
195
194
 
196
195
  i18n.reload!
197
- i18n.one.should == 2
196
+ expect(i18n.one).to eq(2)
198
197
  end
199
198
 
200
199
  it "returns translations" do
201
200
  i18n = R18n::I18n.new('en', DIR)
202
- i18n.t.should be_a(R18n::Translation)
203
- i18n.t.one.should == 'One'
201
+ expect(i18n.t).to be_kind_of(R18n::Translation)
202
+ expect(i18n.t.one).to eq('One')
204
203
  end
205
204
 
206
205
  it "returns first locale with locale file" do
207
206
  i18n = R18n::I18n.new(['notransl', 'nolocale', 'ru', 'en'], DIR)
208
- i18n.locale.should == R18n.locale('nolocale')
209
- i18n.locale.base.should == R18n.locale('ru')
207
+ expect(i18n.locale).to eq(R18n.locale('nolocale'))
208
+ expect(i18n.locale.base).to eq(R18n.locale('ru'))
210
209
  end
211
210
 
212
211
  it "localizes objects" do
213
212
  i18n = R18n::I18n.new('ru')
214
213
 
215
- i18n.l(-123456789).should == '−123 456 789'
216
- i18n.l(-12345.67).should == '−12 345,67'
214
+ expect(i18n.l(-123456789)).to eq('−123 456 789')
215
+ expect(i18n.l(-12345.67)).to eq('−12 345,67')
217
216
 
218
217
  time = Time.at(0).utc
219
- i18n.l(time, '%A').should == 'Четверг'
220
- i18n.l(time, :month).should == 'Январь'
221
- i18n.l(time, :standard).should == '01.01.1970 00:00'
222
- i18n.l(time, :full).should == ' 1 января 1970 00:00'
218
+ expect(i18n.l(time, '%A')).to eq('Четверг')
219
+ expect(i18n.l(time, :month)).to eq('Январь')
220
+ expect(i18n.l(time, :standard)).to eq('01.01.1970 00:00')
221
+ expect(i18n.l(time, :full)).to eq(' 1 января 1970 00:00')
223
222
 
224
- i18n.l(Date.new(0)).should == '01.01.0000'
223
+ expect(i18n.l(Date.new(0))).to eq('01.01.0000')
225
224
  end
226
225
 
227
- it "returns marshalizable values", :not_ruby => 1.8 do
228
- i18n = R18n::I18n.new('en', DIR, :off_filters => :untranslated,
229
- :on_filters => :untranslated_html)
226
+ it "returns marshalizable values" do
227
+ i18n = R18n::I18n.new('en', DIR, off_filters: :untranslated,
228
+ on_filters: :untranslated_html)
230
229
  demarsh = Marshal.load(Marshal.dump(i18n.t.one))
231
230
 
232
- i18n.t.one.should == demarsh
233
- i18n.t.one.path.should == demarsh.path
234
- i18n.t.one.locale.should == demarsh.locale
231
+ expect(i18n.t.one).to eq(demarsh)
232
+ expect(i18n.t.one.path).to eq(demarsh.path)
233
+ expect(i18n.t.one.locale).to eq(demarsh.locale)
235
234
 
236
235
  demarsh = Marshal.load(Marshal.dump(i18n.t.no_translation))
237
- i18n.t.no_translation.should == demarsh
236
+ expect(i18n.t.no_translation).to eq(demarsh)
238
237
  end
239
-
240
238
  end
data/spec/locale_spec.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
  require 'bigdecimal'
4
3
 
@@ -9,100 +8,100 @@ describe R18n::Locale do
9
8
  end
10
9
 
11
10
  it "returns all available locales" do
12
- R18n::Locale.available.class.should == Array
13
- R18n::Locale.available.should_not be_empty
11
+ expect(R18n::Locale.available.class).to eq(Array)
12
+ expect(R18n::Locale.available).not_to be_empty
14
13
  end
15
14
 
16
15
  it "checks is locale exists" do
17
- R18n::Locale.exists?('ru').should be_true
18
- R18n::Locale.exists?('nolocale').should be_false
16
+ expect(R18n::Locale.exists?('ru')).to be true
17
+ expect(R18n::Locale.exists?('nolocale')).to be false
19
18
  end
20
19
 
21
20
  it "sets locale properties" do
22
21
  locale_class = Class.new(R18n::Locale) do
23
- set :one => 1
24
- set :two => 2
22
+ set one: 1
23
+ set two: 2
25
24
  end
26
25
  locale = locale_class.new
27
- locale.one.should == 1
28
- locale.two.should == 2
26
+ expect(locale.one).to eq(1)
27
+ expect(locale.two).to eq(2)
29
28
  end
30
29
 
31
30
  it "loads locale" do
32
- @ru.class.should == R18n::Locales::Ru
33
- @ru.code.should == 'ru'
34
- @ru.title.should == 'Русский'
31
+ expect(@ru.class).to eq(R18n::Locales::Ru)
32
+ expect(@ru.code).to eq('ru')
33
+ expect(@ru.title).to eq('Русский')
35
34
  end
36
35
 
37
36
  it "loads locale by Symbol" do
38
- R18n.locale(:ru).should == R18n.locale('ru')
37
+ expect(R18n.locale(:ru)).to eq(R18n.locale('ru'))
39
38
  end
40
39
 
41
40
  it "equals to another locale with same code" do
42
- @en.should_not == @ru
43
- @en.should == R18n.locale('en')
41
+ expect(@en).not_to eq(@ru)
42
+ expect(@en).to eq(R18n.locale('en'))
44
43
  end
45
44
 
46
45
  it "prints human readable representation" do
47
- @ru.inspect.should == 'Locale ru (Русский)'
46
+ expect(@ru.inspect).to eq('Locale ru (Русский)')
48
47
  end
49
48
 
50
49
  it "returns pluralization type by elements count" do
51
- @en.pluralize(0).should == 0
52
- @en.pluralize(1).should == 1
53
- @en.pluralize(5).should == 'n'
50
+ expect(@en.pluralize(0)).to eq(0)
51
+ expect(@en.pluralize(1)).to eq(1)
52
+ expect(@en.pluralize(5)).to eq('n')
54
53
  end
55
54
 
56
55
  it "uses UnsupportedLocale if locale file isn't exists" do
57
- @en.should be_supported
56
+ expect(@en).to be_supported
58
57
 
59
58
  unsupported = R18n.locale('nolocale-DL')
60
- unsupported.should_not be_supported
61
- unsupported.should be_a(R18n::UnsupportedLocale)
59
+ expect(unsupported).not_to be_supported
60
+ expect(unsupported).to be_kind_of(R18n::UnsupportedLocale)
62
61
 
63
- unsupported.code.downcase.should == 'nolocale-dl'
64
- unsupported.title.downcase.should == 'nolocale-dl'
65
- unsupported.ltr?.should be_true
62
+ expect(unsupported.code.downcase).to eq('nolocale-dl')
63
+ expect(unsupported.title.downcase).to eq('nolocale-dl')
64
+ expect(unsupported.ltr?).to be true
66
65
 
67
- unsupported.pluralize(5).should == 'n'
68
- unsupported.inspect.downcase.should == 'unsupported locale nolocale-dl'
66
+ expect(unsupported.pluralize(5)).to eq('n')
67
+ expect(unsupported.inspect.downcase).to eq('unsupported locale nolocale-dl')
69
68
  end
70
69
 
71
70
  it "formats number in local traditions" do
72
- @en.localize(-123456789).should == "−123,456,789"
71
+ expect(@en.localize(-123456789)).to eq("−123,456,789")
73
72
  end
74
73
 
75
74
  it "formats float in local traditions" do
76
- @en.localize(-12345.67).should == "−12,345.67"
77
- @en.localize(BigDecimal.new("-12345.67")).should == "−12,345.67"
75
+ expect(@en.localize(-12345.67)).to eq("−12,345.67")
76
+ expect(@en.localize(BigDecimal.new("-12345.67"))).to eq("−12,345.67")
78
77
  end
79
78
 
80
79
  it "translates month, week days and am/pm names in strftime" do
81
80
  i18n = R18n::I18n.new('ru')
82
81
  time = Time.at(0).utc
83
82
 
84
- @ru.localize(time, '%a %A').should == 'Чтв Четверг'
85
- @ru.localize(time, '%b %B').should == 'янв января'
86
- @ru.localize(time, '%H:%M%p').should == '00:00 утра'
83
+ expect(@ru.localize(time, '%a %A')).to eq('Чтв Четверг')
84
+ expect(@ru.localize(time, '%b %B')).to eq('янв января')
85
+ expect(@ru.localize(time, '%H:%M%p')).to eq('00:00 утра')
87
86
  end
88
87
 
89
88
  it "generates locale code by locale class name" do
90
- R18n.locale('ru').code.should == 'ru'
91
- R18n.locale('zh-CN').code.should == 'zh-CN'
89
+ expect(R18n.locale('ru').code).to eq('ru')
90
+ expect(R18n.locale('zh-CN').code).to eq('zh-CN')
92
91
  end
93
92
 
94
93
  it "localizes date for human" do
95
94
  i18n = R18n::I18n.new('en')
96
95
 
97
- @en.localize(Date.today + 2, :human, i18n).should == 'after 2 days'
98
- @en.localize(Date.today + 1, :human, i18n).should == 'tomorrow'
99
- @en.localize(Date.today, :human, i18n).should == 'today'
100
- @en.localize(Date.today - 1, :human, i18n).should == 'yesterday'
101
- @en.localize(Date.today - 3, :human, i18n).should == '3 days ago'
96
+ expect(@en.localize(Date.today + 2, :human, i18n)).to eq('after 2 days')
97
+ expect(@en.localize(Date.today + 1, :human, i18n)).to eq('tomorrow')
98
+ expect(@en.localize(Date.today, :human, i18n)).to eq('today')
99
+ expect(@en.localize(Date.today - 1, :human, i18n)).to eq('yesterday')
100
+ expect(@en.localize(Date.today - 3, :human, i18n)).to eq('3 days ago')
102
101
 
103
- y2k = Date.parse('2000-01-08')
104
- @en.localize(y2k, :human, i18n, y2k + 8 ).should == '8th of January'
105
- @en.localize(y2k, :human, i18n, y2k - 365).should == '8th of January, 2000'
102
+ y2k = Date.parse('2000-05-08')
103
+ expect(@en.localize(y2k, :human, i18n, y2k + 8 )).to eq('8th of May')
104
+ expect(@en.localize(y2k, :human, i18n, y2k - 365)).to eq('8th of May, 2000')
106
105
  end
107
106
 
108
107
  it "localizes times for human" do
@@ -112,62 +111,63 @@ describe R18n::Locale do
112
111
  zero = Time.at(0).utc
113
112
  p = [:human, R18n::I18n.new('en'), zero]
114
113
 
115
- @en.localize( zero + 7 * day, *p).should == '8th of January 00:00'
116
- @en.localize( zero + 50 * hour, *p).should == 'after 2 days 02:00'
117
- @en.localize( zero + 25 * hour, *p).should == 'tomorrow 01:00'
118
- @en.localize( zero + 70 * minute, *p).should == 'after 1 hour'
119
- @en.localize( zero + hour, *p).should == 'after 1 hour'
120
- @en.localize( zero + 38 * minute, *p).should == 'after 38 minutes'
121
- @en.localize( zero + 5, *p).should == 'now'
122
- @en.localize( zero - 15, *p).should == 'now'
123
- @en.localize( zero - minute, *p).should == '1 minute ago'
124
- @en.localize( zero - hour + 59, *p).should == '59 minutes ago'
125
- @en.localize( zero - 2 * hour, *p).should == '2 hours ago'
126
- @en.localize( zero - 13 * hour, *p).should == 'yesterday 11:00'
127
- @en.localize( zero - 50 * hour, *p).should == '3 days ago 22:00'
128
-
129
- @en.localize( zero - 9 * day, *p).should == '23rd of December, 1969 00:00'
130
- @en.localize( zero - 365 * day, *p).should == '1st of January, 1969 00:00'
114
+ expect(@en.localize( zero + 7 * day, *p)).to eq('8th of January 00:00')
115
+ expect(@en.localize( zero + 50 * hour, *p)).to eq('after 2 days 02:00')
116
+ expect(@en.localize( zero + 25 * hour, *p)).to eq('tomorrow 01:00')
117
+ expect(@en.localize( zero + 70 * minute, *p)).to eq('after 1 hour')
118
+ expect(@en.localize( zero + hour, *p)).to eq('after 1 hour')
119
+ expect(@en.localize( zero + 38 * minute, *p)).to eq('after 38 minutes')
120
+ expect(@en.localize( zero + 5, *p)).to eq('now')
121
+ expect(@en.localize( zero - 15, *p)).to eq('now')
122
+ expect(@en.localize( zero - minute, *p)).to eq('1 minute ago')
123
+ expect(@en.localize( zero - hour + 59, *p)).to eq('59 minutes ago')
124
+ expect(@en.localize( zero - 2 * hour, *p)).to eq('2 hours ago')
125
+ expect(@en.localize( zero - 13 * hour, *p)).to eq('yesterday 11:00')
126
+ expect(@en.localize( zero - 50 * hour, *p)).to eq('3 days ago 22:00')
127
+
128
+ expect(@en.localize( zero - 9 * day, *p)).to eq(
129
+ '23rd of December, 1969 00:00')
130
+ expect(@en.localize( zero - 365 * day, *p)).to eq(
131
+ '1st of January, 1969 00:00')
131
132
  end
132
133
 
133
134
  it "uses standard formatter by default" do
134
- @ru.localize(Time.at(0).utc).should == '01.01.1970 00:00'
135
+ expect(@ru.localize(Time.at(0).utc)).to eq('01.01.1970 00:00')
135
136
  end
136
137
 
137
138
  it "doesn't localize time without i18n object" do
138
- @ru.localize(Time.at(0)).should_not == Time.at(0).to_s
139
- @ru.localize(Time.at(0), :full).should_not == Time.at(0).to_s
139
+ expect(@ru.localize(Time.at(0))).not_to eq(Time.at(0).to_s)
140
+ expect(@ru.localize(Time.at(0), :full)).not_to eq(Time.at(0).to_s)
140
141
 
141
- @ru.localize(Time.at(0), :human).should == Time.at(0).to_s
142
+ expect(@ru.localize(Time.at(0), :human)).to eq(Time.at(0).to_s)
142
143
  end
143
144
 
144
145
  it "raises error on unknown formatter" do
145
- lambda {
146
+ expect {
146
147
  @ru.localize(Time.at(0).utc, R18n::I18n.new('ru'), :unknown)
147
- }.should raise_error(ArgumentError, /formatter/)
148
+ }.to raise_error(ArgumentError, /formatter/)
148
149
  end
149
150
 
150
151
  it "deletes slashed from locale for security reasons" do
151
152
  locale = R18n.locale('../spec/translations/general/en')
152
- locale.should be_a(R18n::UnsupportedLocale)
153
+ expect(locale).to be_kind_of(R18n::UnsupportedLocale)
153
154
  end
154
155
 
155
156
  it "ignores code case in locales" do
156
157
  upcase = R18n.locale('RU')
157
158
  downcase = R18n.locale('ru')
158
- upcase.should == downcase
159
- upcase.code.should == 'ru'
160
- downcase.code.should == 'ru'
159
+ expect(upcase).to eq(downcase)
160
+ expect(upcase.code).to eq('ru')
161
+ expect(downcase.code).to eq('ru')
161
162
 
162
163
  upcase = R18n.locale('nolocale')
163
164
  downcase = R18n.locale('nolocale')
164
- upcase.should == downcase
165
- upcase.code.should == 'nolocale'
166
- downcase.code.should == 'nolocale'
165
+ expect(upcase).to eq(downcase)
166
+ expect(upcase.code).to eq('nolocale')
167
+ expect(downcase.code).to eq('nolocale')
167
168
  end
168
169
 
169
170
  it "loads locale with underscore" do
170
- R18n.locale('nolocale-DL').code.should == 'nolocale-dl'
171
+ expect(R18n.locale('nolocale-DL').code).to eq('nolocale-dl')
171
172
  end
172
-
173
173
  end
@@ -3,21 +3,21 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::Cs do
4
4
  it "uses Czech pluralization" do
5
5
  cs = R18n.locale('cs')
6
- cs.pluralize(0).should == 0
7
- cs.pluralize(1).should == 1
6
+ expect(cs.pluralize(0)).to eq(0)
7
+ expect(cs.pluralize(1)).to eq(1)
8
8
 
9
- cs.pluralize(2).should == 2
10
- cs.pluralize(3).should == 2
11
- cs.pluralize(4).should == 2
9
+ expect(cs.pluralize(2)).to eq(2)
10
+ expect(cs.pluralize(3)).to eq(2)
11
+ expect(cs.pluralize(4)).to eq(2)
12
12
 
13
- cs.pluralize(5).should == 'n'
14
- cs.pluralize(21).should == 'n'
15
- cs.pluralize(11).should == 'n'
16
- cs.pluralize(12).should == 'n'
17
- cs.pluralize(22).should == 'n'
18
- cs.pluralize(57).should == 'n'
19
- cs.pluralize(101).should == 'n'
20
- cs.pluralize(102).should == 'n'
21
- cs.pluralize(111).should == 'n'
13
+ expect(cs.pluralize(5)).to eq('n')
14
+ expect(cs.pluralize(21)).to eq('n')
15
+ expect(cs.pluralize(11)).to eq('n')
16
+ expect(cs.pluralize(12)).to eq('n')
17
+ expect(cs.pluralize(22)).to eq('n')
18
+ expect(cs.pluralize(57)).to eq('n')
19
+ expect(cs.pluralize(101)).to eq('n')
20
+ expect(cs.pluralize(102)).to eq('n')
21
+ expect(cs.pluralize(111)).to eq('n')
22
22
  end
23
23
  end
@@ -3,11 +3,11 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::EnUs do
4
4
  it "formats American English date" do
5
5
  enUS = R18n::I18n.new('en-US')
6
- enUS.l(Date.parse('2009-05-01'), :full).should == 'May 1st, 2009'
7
- enUS.l(Date.parse('2009-05-02'), :full).should == 'May 2nd, 2009'
8
- enUS.l(Date.parse('2009-05-03'), :full).should == 'May 3rd, 2009'
9
- enUS.l(Date.parse('2009-05-04'), :full).should == 'May 4th, 2009'
10
- enUS.l(Date.parse('2009-05-11'), :full).should == 'May 11th, 2009'
11
- enUS.l(Date.parse('2009-05-21'), :full).should == 'May 21st, 2009'
6
+ expect(enUS.l(Date.parse('2009-05-01'), :full)).to eq('May 1st, 2009')
7
+ expect(enUS.l(Date.parse('2009-05-02'), :full)).to eq('May 2nd, 2009')
8
+ expect(enUS.l(Date.parse('2009-05-03'), :full)).to eq('May 3rd, 2009')
9
+ expect(enUS.l(Date.parse('2009-05-04'), :full)).to eq('May 4th, 2009')
10
+ expect(enUS.l(Date.parse('2009-05-11'), :full)).to eq('May 11th, 2009')
11
+ expect(enUS.l(Date.parse('2009-05-21'), :full)).to eq('May 21st, 2009')
12
12
  end
13
13
  end
@@ -3,11 +3,11 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::En do
4
4
  it "formats English date" do
5
5
  en = R18n::I18n.new('en')
6
- en.l(Date.parse('2009-05-01'), :full).should == '1st of May, 2009'
7
- en.l(Date.parse('2009-05-02'), :full).should == '2nd of May, 2009'
8
- en.l(Date.parse('2009-05-03'), :full).should == '3rd of May, 2009'
9
- en.l(Date.parse('2009-05-04'), :full).should == '4th of May, 2009'
10
- en.l(Date.parse('2009-05-11'), :full).should == '11th of May, 2009'
11
- en.l(Date.parse('2009-05-21'), :full).should == '21st of May, 2009'
6
+ expect(en.l(Date.parse('2009-05-01'), :full)).to eq('1st of May, 2009')
7
+ expect(en.l(Date.parse('2009-05-02'), :full)).to eq('2nd of May, 2009')
8
+ expect(en.l(Date.parse('2009-05-03'), :full)).to eq('3rd of May, 2009')
9
+ expect(en.l(Date.parse('2009-05-04'), :full)).to eq('4th of May, 2009')
10
+ expect(en.l(Date.parse('2009-05-11'), :full)).to eq('11th of May, 2009')
11
+ expect(en.l(Date.parse('2009-05-21'), :full)).to eq('21st of May, 2009')
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::Fr do
4
4
  it "formats French date" do
5
5
  fr = R18n::I18n.new('fr')
6
- fr.l(Date.parse('2009-07-01'), :full).should == '1er juillet 2009'
7
- fr.l(Date.parse('2009-07-02'), :full).should == ' 2 juillet 2009'
6
+ expect(fr.l(Date.parse('2009-07-01'), :full)).to eq('1er juillet 2009')
7
+ expect(fr.l(Date.parse('2009-07-02'), :full)).to eq(' 2 juillet 2009')
8
8
  end
9
9
  end