r18n-core 1.1.11 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,18 +1,17 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../../spec_helper', __FILE__)
3
2
 
4
3
  describe R18n::Locales::Hu do
5
4
  it "uses Hungarian digits groups" do
6
5
  hu = R18n::I18n.new('hu')
7
- hu.l(1000).should == '1000'
8
- hu.l(10000).should == '10 000'
9
- hu.l(-10000).should == '−10 000'
10
- hu.l(100000).should == '100 000'
6
+ expect(hu.l(1000)).to eq('1000')
7
+ expect(hu.l(10000)).to eq('10 000')
8
+ expect(hu.l(-10000)).to eq('−10 000')
9
+ expect(hu.l(100000)).to eq('100 000')
11
10
  end
12
11
 
13
12
  it "uses Hungarian time format" do
14
13
  hu = R18n::I18n.new('hu')
15
- hu.l(Time.at(0).utc).should == '1970. 01. 01., 00:00'
16
- hu.l(Time.at(0).utc, :full).should == '1970. január 1., 00:00'
14
+ expect(hu.l(Time.at(0).utc)).to eq('1970. 01. 01., 00:00')
15
+ expect(hu.l(Time.at(0).utc, :full)).to eq('1970. január 1., 00:00')
17
16
  end
18
17
  end
@@ -1,11 +1,10 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../../spec_helper', __FILE__)
3
2
 
4
3
  describe R18n::Locales::It do
5
4
  it "formats Italian date" do
6
5
  italian = R18n::I18n.new('it')
7
- italian.l(Date.parse('2009-07-01'), :full).should == "1º luglio 2009"
8
- italian.l(Date.parse('2009-07-02'), :full).should == ' 2 luglio 2009'
9
- italian.l(Date.parse('2009-07-12'), :full).should == '12 luglio 2009'
6
+ expect(italian.l(Date.parse('2009-07-01'), :full)).to eq("1º luglio 2009")
7
+ expect(italian.l(Date.parse('2009-07-02'), :full)).to eq(' 2 luglio 2009')
8
+ expect(italian.l(Date.parse('2009-07-12'), :full)).to eq('12 luglio 2009')
10
9
  end
11
10
  end
@@ -3,21 +3,21 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::Pl do
4
4
  it "uses Polish pluralization" do
5
5
  pl = R18n.locale('pl')
6
- pl.pluralize(0).should == 0
7
- pl.pluralize(1).should == 1
6
+ expect(pl.pluralize(0)).to eq(0)
7
+ expect(pl.pluralize(1)).to eq(1)
8
8
 
9
- pl.pluralize(2).should == 2
10
- pl.pluralize(4).should == 2
11
- pl.pluralize(22).should == 2
12
- pl.pluralize(102).should == 2
9
+ expect(pl.pluralize(2)).to eq(2)
10
+ expect(pl.pluralize(4)).to eq(2)
11
+ expect(pl.pluralize(22)).to eq(2)
12
+ expect(pl.pluralize(102)).to eq(2)
13
13
 
14
- pl.pluralize(5).should == 'n'
15
- pl.pluralize(11).should == 'n'
16
- pl.pluralize(12).should == 'n'
17
- pl.pluralize(21).should == 'n'
18
- pl.pluralize(57).should == 'n'
19
- pl.pluralize(101).should == 'n'
20
- pl.pluralize(111).should == 'n'
21
- pl.pluralize(112).should == 'n'
14
+ expect(pl.pluralize(5)).to eq('n')
15
+ expect(pl.pluralize(11)).to eq('n')
16
+ expect(pl.pluralize(12)).to eq('n')
17
+ expect(pl.pluralize(21)).to eq('n')
18
+ expect(pl.pluralize(57)).to eq('n')
19
+ expect(pl.pluralize(101)).to eq('n')
20
+ expect(pl.pluralize(111)).to eq('n')
21
+ expect(pl.pluralize(112)).to eq('n')
22
22
  end
23
23
  end
@@ -3,21 +3,21 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::Ru do
4
4
  it "uses Russian pluralization" do
5
5
  ru = R18n.locale('ru')
6
- ru.pluralize(0).should == 0
6
+ expect(ru.pluralize(0)).to eq(0)
7
7
 
8
- ru.pluralize(1).should == 1
9
- ru.pluralize(21).should == 1
10
- ru.pluralize(101).should == 1
8
+ expect(ru.pluralize(1)).to eq(1)
9
+ expect(ru.pluralize(21)).to eq(1)
10
+ expect(ru.pluralize(101)).to eq(1)
11
11
 
12
- ru.pluralize(2).should == 2
13
- ru.pluralize(4).should == 2
14
- ru.pluralize(22).should == 2
15
- ru.pluralize(102).should == 2
12
+ expect(ru.pluralize(2)).to eq(2)
13
+ expect(ru.pluralize(4)).to eq(2)
14
+ expect(ru.pluralize(22)).to eq(2)
15
+ expect(ru.pluralize(102)).to eq(2)
16
16
 
17
- ru.pluralize(5).should == 'n'
18
- ru.pluralize(11).should == 'n'
19
- ru.pluralize(12).should == 'n'
20
- ru.pluralize(57).should == 'n'
21
- ru.pluralize(111).should == 'n'
17
+ expect(ru.pluralize(5)).to eq('n')
18
+ expect(ru.pluralize(11)).to eq('n')
19
+ expect(ru.pluralize(12)).to eq('n')
20
+ expect(ru.pluralize(57)).to eq('n')
21
+ expect(ru.pluralize(111)).to eq('n')
22
22
  end
23
23
  end
@@ -3,21 +3,21 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::Sk do
4
4
  it "uses Slovak pluralization" do
5
5
  sk = R18n.locale('Sk')
6
- sk.pluralize(0).should == 0
7
- sk.pluralize(1).should == 1
6
+ expect(sk.pluralize(0)).to eq(0)
7
+ expect(sk.pluralize(1)).to eq(1)
8
8
 
9
- sk.pluralize(2).should == 2
10
- sk.pluralize(3).should == 2
11
- sk.pluralize(4).should == 2
9
+ expect(sk.pluralize(2)).to eq(2)
10
+ expect(sk.pluralize(3)).to eq(2)
11
+ expect(sk.pluralize(4)).to eq(2)
12
12
 
13
- sk.pluralize(5).should == 'n'
14
- sk.pluralize(21).should == 'n'
15
- sk.pluralize(11).should == 'n'
16
- sk.pluralize(12).should == 'n'
17
- sk.pluralize(22).should == 'n'
18
- sk.pluralize(57).should == 'n'
19
- sk.pluralize(101).should == 'n'
20
- sk.pluralize(102).should == 'n'
21
- sk.pluralize(111).should == 'n'
13
+ expect(sk.pluralize(5)).to eq('n')
14
+ expect(sk.pluralize(21)).to eq('n')
15
+ expect(sk.pluralize(11)).to eq('n')
16
+ expect(sk.pluralize(12)).to eq('n')
17
+ expect(sk.pluralize(22)).to eq('n')
18
+ expect(sk.pluralize(57)).to eq('n')
19
+ expect(sk.pluralize(101)).to eq('n')
20
+ expect(sk.pluralize(102)).to eq('n')
21
+ expect(sk.pluralize(111)).to eq('n')
22
22
  end
23
23
  end
@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe R18n::Locales::Ru do
4
4
  it "uses Thai calendar" do
5
5
  th = R18n::I18n.new('th')
6
- th.l(Time.at(0).utc, '%Y %y').should == '2513 13'
7
- th.l(Time.at(0).utc).should == '01/01/2513 00:00'
6
+ expect(th.l(Time.at(0).utc, '%Y %y')).to eq('2513 13')
7
+ expect(th.l(Time.at(0).utc)).to eq('01/01/2513 00:00')
8
8
  end
9
9
  end
data/spec/r18n_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 do
@@ -13,10 +12,10 @@ describe R18n do
13
12
  it "stores I18n" do
14
13
  i18n = R18n::I18n.new('en')
15
14
  R18n.set(i18n)
16
- R18n.get.should == i18n
15
+ expect(R18n.get).to eq(i18n)
17
16
 
18
17
  R18n.reset!
19
- R18n.get.should be_nil
18
+ expect(R18n.get).to be_nil
20
19
  end
21
20
 
22
21
  it "sets setter to I18n" do
@@ -26,25 +25,25 @@ describe R18n do
26
25
  i18n = R18n::I18n.new('ru')
27
26
  R18n.set { i18n }
28
27
 
29
- R18n.get.should == i18n
28
+ expect(R18n.get).to eq(i18n)
30
29
  end
31
30
 
32
31
  it "creates I18n object by shortcut" do
33
32
  R18n.set('en', DIR)
34
- R18n.get.should be_a(R18n::I18n)
35
- R18n.get.locales.should == [R18n.locale('en')]
36
- R18n.get.translation_places.should == [R18n::Loader::YAML.new(DIR)]
33
+ expect(R18n.get).to be_kind_of(R18n::I18n)
34
+ expect(R18n.get.locales).to eq([R18n.locale('en')])
35
+ expect(R18n.get.translation_places).to eq([R18n::Loader::YAML.new(DIR)])
37
36
  end
38
37
 
39
38
  it "allows to return I18n arguments in setter block" do
40
39
  R18n.set { 'en' }
41
- R18n.get.locales.should == [R18n.locale('en')]
40
+ expect(R18n.get.locales).to eq([R18n.locale('en')])
42
41
  end
43
42
 
44
43
  it "clears cache" do
45
44
  R18n.cache[:a] = 1
46
45
  R18n.clear_cache!
47
- R18n.cache.should be_empty
46
+ expect(R18n.cache).to be_empty
48
47
  end
49
48
 
50
49
  it "resets I18n objects and cache" do
@@ -53,116 +52,115 @@ describe R18n do
53
52
  R18n.thread_set('en')
54
53
 
55
54
  R18n.reset!
56
- R18n.get.should be_nil
57
- R18n.cache.should be_empty
55
+ expect(R18n.get).to be_nil
56
+ expect(R18n.cache).to be_empty
58
57
  end
59
58
 
60
59
  it "stores I18n via thread_set" do
61
60
  i18n = R18n::I18n.new('en')
62
61
  R18n.thread_set(i18n)
63
- R18n.get.should == i18n
62
+ expect(R18n.get).to eq(i18n)
64
63
 
65
64
  i18n = R18n::I18n.new('ru')
66
65
  R18n.thread_set { i18n }
67
- R18n.get.should == i18n
66
+ expect(R18n.get).to eq(i18n)
68
67
  end
69
68
 
70
69
  it "allows to temporary change locale" do
71
70
  R18n.default_places = DIR
72
- R18n.change('en').locales.should == [R18n.locale('en')]
73
- R18n.change('en').should have(1).translation_places
74
- R18n.change('en').translation_places.first.dir.should == DIR.to_s
71
+ expect(R18n.change('en').locales).to eq([R18n.locale('en')])
72
+ expect(R18n.change('en').translation_places.size).to eq(1)
73
+ expect(R18n.change('en').translation_places.first.dir).to eq(DIR.to_s)
75
74
  end
76
75
 
77
76
  it "allows to temporary change current locales" do
78
77
  R18n.set('ru')
79
- R18n.change('en').locales.should == [R18n.locale('en'), R18n.locale('ru')]
80
- R18n.change('en').translation_places.should == R18n.get.translation_places
81
- R18n.get.locale.code.should.should == 'ru'
78
+ expect(R18n.change('en').locales).to eq(
79
+ [R18n.locale('en'), R18n.locale('ru')])
80
+ expect(R18n.change('en').translation_places).to eq(
81
+ R18n.get.translation_places)
82
+ expect(R18n.get.locale.code).to eq('ru')
82
83
  end
83
84
 
84
85
  it "allows to get Locale to temporary change" do
85
86
  R18n.set('ru')
86
- R18n.change(R18n.locale('en')).locale.code.should == 'en'
87
+ expect(R18n.change(R18n.locale('en')).locale.code).to eq('en')
87
88
  end
88
89
 
89
90
  it "has shortcut to load locale" do
90
- R18n.locale('ru').should == R18n::Locale.load('ru')
91
+ expect(R18n.locale('ru')).to eq(R18n::Locale.load('ru'))
91
92
  end
92
93
 
93
94
  it "stores default loader class" do
94
- R18n.default_loader.should == R18n::Loader::YAML
95
+ expect(R18n.default_loader).to eq(R18n::Loader::YAML)
95
96
  R18n.default_loader = Class
96
- R18n.default_loader.should == Class
97
+ expect(R18n.default_loader).to be_kind_of(Class)
97
98
  end
98
99
 
99
100
  it "stores cache" do
100
- R18n.cache.should be_a(Hash)
101
+ expect(R18n.cache).to be_kind_of(Hash)
101
102
 
102
103
  R18n.cache = { 1 => 2 }
103
- R18n.cache.should == { 1 => 2 }
104
+ expect(R18n.cache).to eq({ 1 => 2 })
104
105
 
105
106
  R18n.clear_cache!
106
- R18n.cache.should == { }
107
- end
108
-
109
- it "converts Time to Date" do
110
- R18n::Utils.to_date(Time.now).should == Date.today
107
+ expect(R18n.cache).to eq({ })
111
108
  end
112
109
 
113
110
  it "maps hash" do
114
- R18n::Utils.hash_map({'a' => 1, 'b' => 2}) { |k, v| [k + 'a', v + 1] }.
115
- should == { 'aa' => 2, 'ba' => 3 }
111
+ hash = R18n::Utils.hash_map({ 'a' => 1, 'b' => 2 }) { |k, v|
112
+ [k + 'a', v + 1]
113
+ }
114
+ expect(hash).to eq({ 'aa' => 2, 'ba' => 3 })
116
115
  end
117
116
 
118
117
  it "merges hash recursively" do
119
- a = { :a => 1, :b => {:ba => 1, :bb => 1}, :c => 1 }
120
- b = { :b => {:bb => 2, :bc => 2}, :c => 2 }
118
+ a = { a: 1, b: { ba: 1, bb: 1}, c: 1 }
119
+ b = { b: { bb: 2, bc: 2}, c: 2 }
121
120
 
122
121
  R18n::Utils.deep_merge!(a, b)
123
- a.should == { :a => 1, :b => { :ba => 1, :bb => 2, :bc => 2 }, :c => 2 }
122
+ expect(a).to eq({ a: 1, b: { ba: 1, bb: 2, bc: 2 }, c: 2 })
124
123
  end
125
124
 
126
125
  it "has l and t methods" do
127
126
  R18n.set('en')
128
- t.yes.should == 'Yes'
129
- l(Time.at(0).utc).should == '01/01/1970 00:00'
127
+ expect(t.yes).to eq('Yes')
128
+ expect(l(Time.at(0).utc)).to eq('01/01/1970 00:00')
130
129
  end
131
130
 
132
131
  it "has helpers mixin" do
133
132
  obj = R18n::I18n.new('en')
134
133
  R18n.set(obj)
135
134
 
136
- r18n.should == obj
137
- i18n.should == obj
138
- t.yes.should == 'Yes'
139
- l(Time.at(0).utc).should == '01/01/1970 00:00'
135
+ expect(r18n).to eq(obj)
136
+ expect(i18n).to eq(obj)
137
+ expect(t.yes).to eq('Yes')
138
+ expect(l(Time.at(0).utc)).to eq('01/01/1970 00:00')
140
139
  end
141
140
 
142
141
  it "returns available translations" do
143
- R18n.available_locales(DIR).should =~ [R18n.locale('nolocale'),
142
+ expect(R18n.available_locales(DIR)).to match_array([R18n.locale('nolocale'),
144
143
  R18n.locale('ru'),
145
- R18n.locale('en')]
144
+ R18n.locale('en')])
146
145
  end
147
146
 
148
147
  it "uses default places" do
149
148
  R18n.default_places = DIR
150
149
  R18n.set('en')
151
- t.one.should == 'One'
152
- R18n.available_locales.should =~ [R18n.locale('ru'),
150
+ expect(t.one).to eq('One')
151
+ expect(R18n.available_locales).to match_array([R18n.locale('ru'),
153
152
  R18n.locale('en'),
154
- R18n.locale('nolocale')]
153
+ R18n.locale('nolocale')])
155
154
  end
156
155
 
157
156
  it "sets default places by block" do
158
157
  R18n.default_places { DIR }
159
- R18n.default_places.should == DIR
158
+ expect(R18n.default_places).to eq(DIR)
160
159
  end
161
160
 
162
161
  it "allows to ignore default places" do
163
162
  R18n.default_places = DIR
164
163
  i18n = R18n::I18n.new('en', nil)
165
- i18n.one.should_not be_translated
164
+ expect(i18n.one).not_to be_translated
166
165
  end
167
-
168
166
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require 'pp'
3
2
 
4
3
  dir = Pathname(__FILE__).dirname
@@ -36,9 +35,3 @@ class CounterLoader
36
35
  @available.hash
37
36
  end
38
37
  end
39
-
40
- RSpec.configure do |c|
41
- c.filter_run_excluding :not_ruby => lambda { |version|
42
- RUBY_VERSION.to_s.start_with? version.to_s
43
- }
44
- end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
3
  describe R18n::Translated do
@@ -14,17 +13,17 @@ describe R18n::Translated do
14
13
  end
15
14
 
16
15
  it "saves methods map" do
17
- @user_class.translation :name, :methods => { :ru => :name_ru }
18
- @user_class.unlocalized_getters(:name).should == { 'ru' => 'name_ru' }
19
- @user_class.unlocalized_setters(:name).should == { 'ru' => 'name_ru=' }
16
+ @user_class.translation :name, methods: { ru: :name_ru }
17
+ expect(@user_class.unlocalized_getters(:name)).to eq({ 'ru' => 'name_ru' })
18
+ expect(@user_class.unlocalized_setters(:name)).to eq({ 'ru' => 'name_ru=' })
20
19
  end
21
20
 
22
21
  it "autodetects methods map" do
23
22
  @user_class.translation :name
24
- @user_class.unlocalized_getters(:name).should == {
25
- 'en' => 'name_en', 'ru' => 'name_ru' }
26
- @user_class.unlocalized_setters(:name).should == {
27
- 'en' => 'name_en=', 'ru' => 'name_ru=' }
23
+ expect(@user_class.unlocalized_getters(:name)).to eq({
24
+ 'en' => 'name_en', 'ru' => 'name_ru' })
25
+ expect(@user_class.unlocalized_setters(:name)).to eq({
26
+ 'en' => 'name_en=', 'ru' => 'name_ru=' })
28
27
  end
29
28
 
30
29
  it "translates methods" do
@@ -32,12 +31,12 @@ describe R18n::Translated do
32
31
  user = @user_class.new
33
32
 
34
33
  user.name = 'John'
35
- user.name.should == 'John'
34
+ expect(user.name).to eq('John')
36
35
 
37
36
  R18n.set('ru')
38
- user.name.should == 'John'
37
+ expect(user.name).to eq('John')
39
38
  user.name = 'Джон'
40
- user.name.should == 'Джон'
39
+ expect(user.name).to eq('Джон')
41
40
  end
42
41
 
43
42
  it "returns TranslatedString" do
@@ -48,9 +47,9 @@ describe R18n::Translated do
48
47
  end
49
48
  obj = ::SomeTranslatedClass.new
50
49
 
51
- obj.name.should be_a(R18n::TranslatedString)
52
- obj.name.locale.should == R18n.locale('en')
53
- obj.name.path.should == 'SomeTranslatedClass#name'
50
+ expect(obj.name).to be_kind_of(R18n::TranslatedString)
51
+ expect(obj.name.locale).to eq(R18n.locale('en'))
52
+ expect(obj.name.path).to eq('SomeTranslatedClass#name')
54
53
  end
55
54
 
56
55
  it "searchs translation by locales priority" do
@@ -59,7 +58,7 @@ describe R18n::Translated do
59
58
 
60
59
  R18n.set(['nolocale', 'ru', 'en'])
61
60
  user.name_ru = 'Иван'
62
- user.name.locale.should == R18n.locale('ru')
61
+ expect(user.name.locale).to eq(R18n.locale('ru'))
63
62
  end
64
63
 
65
64
  it "uses default locale" do
@@ -68,42 +67,42 @@ describe R18n::Translated do
68
67
 
69
68
  R18n.set('nolocale')
70
69
  user.name_en = 'John'
71
- user.name.locale.should == R18n.locale('en')
70
+ expect(user.name.locale).to eq(R18n.locale('en'))
72
71
  end
73
72
 
74
73
  it "uses filters" do
75
74
  @user_class.class_eval do
76
75
  def age_en; {1 => '%1 year', 'n' => '%1 years'} end
77
- translation :age, :type => 'pl', :no_params => true
76
+ translation :age, type: 'pl', no_params: true
78
77
  end
79
78
  user = @user_class.new
80
79
 
81
- user.age(20).should == '20 years'
80
+ expect(user.age(20)).to eq('20 years')
82
81
  end
83
82
 
84
83
  it "sends params to method if user want it" do
85
84
  @user_class.class_eval do
86
85
  def no_params_en(*params) params.join(' '); end
87
86
  def params_en(*params) params.join(' '); end
88
- translations [:no_params, {:no_params => true}], :params
87
+ translations [:no_params, { no_params: true }], :params
89
88
  end
90
89
  user = @user_class.new
91
90
 
92
- user.no_params(1, 2).should == ''
93
- user.params(1, 2).should == '1 2'
91
+ expect(user.no_params(1, 2)).to eq('')
92
+ expect(user.params(1, 2)).to eq('1 2')
94
93
  end
95
94
 
96
95
  it "translates virtual methods" do
97
96
  @virtual_class = Class.new do
98
97
  include R18n::Translated
99
- translation :no_method, :methods => { :en => :no_method_en }
98
+ translation :no_method, methods: { en: :no_method_en }
100
99
  def method_missing(name, *params)
101
100
  name.to_s
102
101
  end
103
102
  end
104
103
  virtual = @virtual_class.new
105
104
 
106
- virtual.no_method.should == 'no_method_en'
105
+ expect(virtual.no_method).to eq('no_method_en')
107
106
  end
108
107
 
109
108
  it "returns original type of result" do
@@ -115,7 +114,7 @@ describe R18n::Translated do
115
114
  end
116
115
  user = @user_class.new
117
116
 
118
- user.name.should == :ivan
117
+ expect(user.name).to eq(:ivan)
119
118
  end
120
119
 
121
120
  it "returns nil" do
@@ -127,7 +126,7 @@ describe R18n::Translated do
127
126
  end
128
127
  user = @user_class.new
129
128
 
130
- user.name.should be_nil
129
+ expect(user.name).to be_nil
131
130
  end
132
131
 
133
132
  it "allows to change I18n object" do
@@ -140,9 +139,8 @@ describe R18n::Translated do
140
139
  user.name_en = 'John'
141
140
 
142
141
  user.r18n = R18n::I18n.new('ru')
143
- user.name.should == 'Иван'
142
+ expect(user.name).to eq('Иван')
144
143
  user.r18n = R18n::I18n.new('en')
145
- user.name.should == 'John'
144
+ expect(user.name).to eq('John')
146
145
  end
147
-
148
146
  end