twitter_cldr 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/History.txt +4 -0
  4. data/README.md +17 -6
  5. data/lib/twitter_cldr/resources/postal_codes_importer.rb +12 -1
  6. data/lib/twitter_cldr/resources/regexp_ast_generator.rb +41 -0
  7. data/lib/twitter_cldr/resources.rb +1 -0
  8. data/lib/twitter_cldr/shared/postal_code_generator.rb +50 -0
  9. data/lib/twitter_cldr/shared/postal_codes.rb +48 -9
  10. data/lib/twitter_cldr/shared.rb +15 -14
  11. data/lib/twitter_cldr/utils/regexp_ast.rb +115 -0
  12. data/lib/twitter_cldr/utils/regexp_sampler.rb +149 -0
  13. data/lib/twitter_cldr/utils.rb +5 -3
  14. data/lib/twitter_cldr/version.rb +1 -1
  15. data/resources/shared/postal_codes.yml +1442 -159
  16. data/spec/bidi/bidi_spec.rb +1 -1
  17. data/spec/collation/collation_spec.rb +1 -1
  18. data/spec/collation/collator_spec.rb +31 -31
  19. data/spec/collation/implicit_collation_elements_spec.rb +6 -6
  20. data/spec/collation/sort_key_builder_spec.rb +28 -26
  21. data/spec/collation/tailoring_spec.rb +1 -1
  22. data/spec/collation/trie_builder_spec.rb +16 -16
  23. data/spec/collation/trie_dumps_spec.rb +2 -2
  24. data/spec/collation/trie_loader_spec.rb +8 -8
  25. data/spec/collation/trie_spec.rb +61 -61
  26. data/spec/collation/trie_with_fallback_spec.rb +5 -5
  27. data/spec/core_ext_spec.rb +1 -1
  28. data/spec/data_readers/additional_date_format_selector_spec.rb +38 -38
  29. data/spec/data_readers/date_time_data_reader_spec.rb +2 -2
  30. data/spec/data_readers/number_data_reader_spec.rb +1 -1
  31. data/spec/formatters/calendars/datetime_formatter_spec.rb +218 -218
  32. data/spec/formatters/list_formatter_spec.rb +8 -8
  33. data/spec/formatters/numbers/abbreviated/abbreviated_number_formatter_spec.rb +14 -14
  34. data/spec/formatters/numbers/abbreviated/long_decimal_formatter_spec.rb +4 -4
  35. data/spec/formatters/numbers/abbreviated/short_decimal_formatter_spec.rb +4 -4
  36. data/spec/formatters/numbers/currency_formatter_spec.rb +11 -11
  37. data/spec/formatters/numbers/decimal_formatter_spec.rb +3 -3
  38. data/spec/formatters/numbers/helpers/fraction_spec.rb +3 -3
  39. data/spec/formatters/numbers/helpers/integer_spec.rb +16 -16
  40. data/spec/formatters/numbers/number_formatter_spec.rb +21 -21
  41. data/spec/formatters/numbers/percent_formatter_spec.rb +3 -3
  42. data/spec/formatters/numbers/rbnf/rbnf_spec.rb +2 -2
  43. data/spec/formatters/plurals/plural_formatter_spec.rb +41 -41
  44. data/spec/formatters/plurals/rules_spec.rb +13 -13
  45. data/spec/localized/localized_array_spec.rb +12 -12
  46. data/spec/localized/localized_date_spec.rb +33 -33
  47. data/spec/localized/localized_datetime_spec.rb +11 -11
  48. data/spec/localized/localized_hash_spec.rb +4 -4
  49. data/spec/localized/localized_number_spec.rb +36 -36
  50. data/spec/localized/localized_object_spec.rb +8 -8
  51. data/spec/localized/localized_string_spec.rb +53 -53
  52. data/spec/localized/localized_symbol_spec.rb +9 -9
  53. data/spec/localized/localized_time_spec.rb +10 -10
  54. data/spec/localized/localized_timespan_spec.rb +8 -8
  55. data/spec/normalization_spec.rb +6 -6
  56. data/spec/parsers/number_parser_spec.rb +36 -36
  57. data/spec/parsers/parser_spec.rb +5 -5
  58. data/spec/parsers/segmentation_parser_spec.rb +19 -19
  59. data/spec/parsers/symbol_table_spec.rb +4 -4
  60. data/spec/parsers/unicode_regex/character_class_spec.rb +19 -19
  61. data/spec/parsers/unicode_regex/character_range_spec.rb +1 -1
  62. data/spec/parsers/unicode_regex/character_set_spec.rb +8 -8
  63. data/spec/parsers/unicode_regex/literal_spec.rb +5 -5
  64. data/spec/parsers/unicode_regex/unicode_string_spec.rb +2 -2
  65. data/spec/parsers/unicode_regex_parser_spec.rb +28 -28
  66. data/spec/resources/loader_spec.rb +32 -32
  67. data/spec/shared/break_iterator_spec.rb +13 -13
  68. data/spec/shared/calendar_spec.rb +59 -59
  69. data/spec/shared/casefolder_spec.rb +5 -5
  70. data/spec/shared/code_point_spec.rb +46 -46
  71. data/spec/shared/currencies_spec.rb +7 -7
  72. data/spec/shared/language_codes_spec.rb +34 -34
  73. data/spec/shared/languages_spec.rb +30 -30
  74. data/spec/shared/numbering_system_spec.rb +7 -7
  75. data/spec/shared/numbers_spec.rb +4 -4
  76. data/spec/shared/phone_codes_spec.rb +7 -7
  77. data/spec/shared/postal_code_generator_spec.rb +76 -0
  78. data/spec/shared/postal_codes_spec.rb +35 -29
  79. data/spec/shared/territories_spec.rb +40 -40
  80. data/spec/shared/unicode_regex_spec.rb +71 -71
  81. data/spec/spec_helper.rb +2 -2
  82. data/spec/tokenizers/calendars/date_tokenizer_spec.rb +1 -1
  83. data/spec/tokenizers/calendars/timespan_tokenizer_spec.rb +6 -6
  84. data/spec/tokenizers/composite_token_spec.rb +3 -3
  85. data/spec/tokenizers/token_spec.rb +3 -3
  86. data/spec/twitter_cldr_spec.rb +72 -72
  87. data/spec/utils/code_points_spec.rb +10 -10
  88. data/spec/utils/interpolation_spec.rb +32 -32
  89. data/spec/utils/range_set_spec.rb +36 -36
  90. data/spec/utils/regexp_ast_spec.rb +44 -0
  91. data/spec/utils/regexp_sampler_spec.rb +182 -0
  92. data/spec/utils/yaml/yaml_spec.rb +23 -23
  93. data/spec/utils_spec.rb +19 -19
  94. metadata +263 -258
@@ -11,11 +11,11 @@ describe PluralFormatter do
11
11
 
12
12
  describe '#initialize' do
13
13
  it 'fetches locale from options hash' do
14
- PluralFormatter.new(:ru).locale.should == :ru
14
+ expect(PluralFormatter.new(:ru).locale).to eq(:ru)
15
15
  end
16
16
 
17
17
  it "uses current locale if it's not passed in options hash" do
18
- PluralFormatter.new.locale.should == TwitterCldr.locale
18
+ expect(PluralFormatter.new.locale).to eq(TwitterCldr.locale)
19
19
  end
20
20
  end
21
21
 
@@ -38,47 +38,47 @@ describe PluralFormatter do
38
38
  context 'when there is nothing to pluralize' do
39
39
  it "doesn't change the string if no interpolation found" do
40
40
  string = 'no interpolation here'
41
- subject.format(string, {}).should == string
41
+ expect(subject.format(string, {})).to eq(string)
42
42
  end
43
43
 
44
44
  context 'with regular pluralization' do
45
45
  it "doesn't change the string if a number is not provided" do
46
46
  string = 'there %{horses_count:horses}'
47
- subject.format(string, :horses => horses).should == string
47
+ expect(subject.format(string, :horses => horses)).to eq(string)
48
48
  end
49
49
 
50
50
  it "doesn't change the string if a patterns hash is not provided" do
51
51
  string = 'there %{horses_count:horses}'
52
- subject.format(string, :horses_count => 1).should == string
52
+ expect(subject.format(string, :horses_count => 1)).to eq(string)
53
53
  end
54
54
 
55
55
  it "doesn't change the string if required pattern is not provided" do
56
56
  string = 'there %{horses_count:horses}'
57
- subject.format(string, :horses_count => 2, :horses => { :one => 'is 1 horse' }).should == string
57
+ expect(subject.format(string, :horses_count => 2, :horses => { :one => 'is 1 horse' })).to eq(string)
58
58
  end
59
59
  end
60
60
 
61
61
  context 'with inline pluralization' do
62
62
  it "doesn't change the string if a number is not provided" do
63
63
  string = "there #{horses_string}"
64
- subject.format(string, {}).should == string
64
+ expect(subject.format(string, {})).to eq(string)
65
65
  end
66
66
 
67
67
  it "doesn't change the string if required pattern is not provided" do
68
68
  string = 'there %<{ "horses_count": {"one": "is 1 horse"} }>'
69
- subject.format(string, :horses_count => 2).should == string
69
+ expect(subject.format(string, :horses_count => 2)).to eq(string)
70
70
  end
71
71
  end
72
72
 
73
73
  context 'with mixed pluralization' do
74
74
  it "doesn't change the string if a number is not provided" do
75
75
  string = "there #{horses_string} %{horses_count:horses}"
76
- subject.format(string, :horses => horses).should == string
76
+ expect(subject.format(string, :horses => horses)).to eq(string)
77
77
  end
78
78
 
79
79
  it "doesn't change the string if required pattern is not provided" do
80
80
  string = 'there %<{ "horses_count": {"one": "is 1 horse"} }> %{horses_count:horses}'
81
- subject.format(string, :horses_count => 2, :horses => { :one => 'is 1 horse' }).should == string
81
+ expect(subject.format(string, :horses_count => 2, :horses => { :one => 'is 1 horse' })).to eq(string)
82
82
  end
83
83
  end
84
84
  end
@@ -86,109 +86,109 @@ describe PluralFormatter do
86
86
  context 'when something should be pluralized' do
87
87
  context 'with regular pluralization' do
88
88
  it 'pluralizes with a simple replacement' do
89
- subject.format(
89
+ expect(subject.format(
90
90
  'there %{horses_count:horses}',
91
91
  :horses_count => 1, :horses => horses
92
- ).should == 'there is 1 horse'
92
+ )).to eq('there is 1 horse')
93
93
  end
94
94
 
95
95
  it 'pluralizes when there are named interpolation patterns in the string' do
96
- subject.format(
96
+ expect(subject.format(
97
97
  '%{there} %{horses_count:horses}',
98
98
  :horses_count => 1, :horses => horses
99
- ).should == '%{there} is 1 horse'
99
+ )).to eq('%{there} is 1 horse')
100
100
  end
101
101
 
102
102
  it 'supports multiple patterns sets for the same number' do
103
- subject.format(
103
+ expect(subject.format(
104
104
  'there %{horses_count:to_be} %{horses_count:horses}',
105
105
  :horses_count => 1, :horses => simple_horses, :to_be => to_be
106
- ).should == 'there is 1 horse'
106
+ )).to eq('there is 1 horse')
107
107
  end
108
108
 
109
109
  it 'pluralizes multiple entries' do
110
- subject.format(
110
+ expect(subject.format(
111
111
  'there %{yaks_count:yaks} and %{horses_count:horses}',
112
112
  :yaks_count => 1, :yaks => yaks, :horses_count => 2, :horses => simple_horses
113
- ).should == 'there is 1 yak and 2 horses'
113
+ )).to eq('there is 1 yak and 2 horses')
114
114
  end
115
115
 
116
116
  it 'substitutes the number for a placeholder in the pattern' do
117
- subject.format(
117
+ expect(subject.format(
118
118
  'there %{horses_count:horses}',
119
119
  :horses_count => 3, :horses => horses
120
- ).should == 'there are 3 horses'
120
+ )).to eq('there are 3 horses')
121
121
  end
122
122
 
123
123
  it 'substitutes the number for multiple placeholders in the pattern' do
124
- subject.format(
124
+ expect(subject.format(
125
125
  'there are %{horses_count:horses}',
126
126
  :horses_count => 3, :horses => { :other => '%{horses_count}, seriously %{horses_count}, horses' }
127
- ).should == 'there are 3, seriously 3, horses'
127
+ )).to eq('there are 3, seriously 3, horses')
128
128
  end
129
129
 
130
130
  it 'throws an exception if pluralization patterns is not a hash' do
131
- lambda do
131
+ expect do
132
132
  subject.format('there %{horses_count:horses}', :horses_count => 1, :horses => [])
133
- end.should raise_error(ArgumentError, 'expected patterns to be a Hash')
133
+ end.to raise_error(ArgumentError, 'expected patterns to be a Hash')
134
134
  end
135
135
  end
136
136
 
137
137
  context 'with inline pluralization' do
138
138
  it 'pluralizes with a simple replacement' do
139
- subject.format("there #{horses_string}", :horses_count => 1).should == 'there is 1 horse'
139
+ expect(subject.format("there #{horses_string}", :horses_count => 1)).to eq('there is 1 horse')
140
140
  end
141
141
 
142
142
  it 'pluralizes when there are named interpolation patterns in the string' do
143
- subject.format("%{there} #{horses_string}", :horses_count => 1).should == '%{there} is 1 horse'
143
+ expect(subject.format("%{there} #{horses_string}", :horses_count => 1)).to eq('%{there} is 1 horse')
144
144
  end
145
145
 
146
146
  it 'supports multiple patterns sets for the same number' do
147
- subject.format(
147
+ expect(subject.format(
148
148
  %Q(there %<{ "horses_count": {"one": "is", "other": "are"} }> #{simple_horses_string}), :horses_count => 1
149
- ).should == 'there is 1 horse'
149
+ )).to eq('there is 1 horse')
150
150
  end
151
151
 
152
152
  it 'pluralizes multiple entries' do
153
- subject.format(
153
+ expect(subject.format(
154
154
  %Q(there %<{ "yaks_count": {"one": "is 1 yak", "other": "are %{yaks_count} yaks"} }> and #{simple_horses_string}),
155
155
  :yaks_count => 1, :horses_count => 2
156
- ).should == 'there is 1 yak and 2 horses'
156
+ )).to eq('there is 1 yak and 2 horses')
157
157
  end
158
158
 
159
159
  it 'substitutes the number for a placeholder in the pattern' do
160
- subject.format(
160
+ expect(subject.format(
161
161
  "there #{horses_string}", :horses_count => 3, :horses => horses
162
- ).should == 'there are 3 horses'
162
+ )).to eq('there are 3 horses')
163
163
  end
164
164
 
165
165
  it 'substitutes the number for multiple placeholders in the pattern' do
166
- subject.format(
166
+ expect(subject.format(
167
167
  'there are %<{ "horses_count": {"other": "%{horses_count}, seriously %{horses_count}, horses"} }>',
168
168
  :horses_count => 3
169
- ).should == 'there are 3, seriously 3, horses'
169
+ )).to eq('there are 3, seriously 3, horses')
170
170
  end
171
171
 
172
172
  it 'throws an exception if pluralization hash has more than one key' do
173
- lambda do
173
+ expect do
174
174
  subject.format('there are %<{ "horses_count": {}, "foo": {} }>', {})
175
- end.should raise_error(ArgumentError, 'expected a Hash with a single key')
175
+ end.to raise_error(ArgumentError, 'expected a Hash with a single key')
176
176
  end
177
177
  end
178
178
 
179
179
  context 'with mixed pluralization' do
180
180
  it 'pluralizes separate groups' do
181
- subject.format(
181
+ expect(subject.format(
182
182
  "there %{yaks_count:yaks} and #{simple_horses_string}",
183
183
  :yaks => yaks, :yaks_count => 3, :horses_count => 2
184
- ).should == 'there are 3 yaks and 2 horses'
184
+ )).to eq('there are 3 yaks and 2 horses')
185
185
  end
186
186
 
187
187
  it 'pluralizes similar groups' do
188
- subject.format(
188
+ expect(subject.format(
189
189
  "there %{horses_count:horses} + #{simple_horses_string}",
190
190
  :horses => horses, :horses_count => 2
191
- ).should == 'there are 2 horses + 2 horses'
191
+ )).to eq('there are 2 horses + 2 horses')
192
192
  end
193
193
  end
194
194
  end
@@ -198,7 +198,7 @@ describe PluralFormatter do
198
198
  describe '#pluralization_rule' do
199
199
  it 'delegates pluralization rule fetching to Rules.rule_for method' do
200
200
  mock(Plurals::Rules).rule_for(42, :jp) { 'result' }
201
- PluralFormatter.new(:jp).send(:pluralization_rule, 42).should == 'result'
201
+ expect(PluralFormatter.new(:jp).send(:pluralization_rule, 42)).to eq('result')
202
202
  end
203
203
  end
204
204
 
@@ -12,17 +12,17 @@ describe Rules do
12
12
  it "calls eval on the hash that gets returned, lambdas and all" do
13
13
  result = Rules.send(:get_resource, :ru)
14
14
 
15
- result.should include(:keys, :rule)
16
- result[:keys].size.should == 3
17
- result[:rule].should be_a(Proc)
15
+ expect(result).to include(:keys, :rule)
16
+ expect(result[:keys].size).to eq(3)
17
+ expect(result[:rule]).to be_a(Proc)
18
18
  end
19
19
  end
20
20
 
21
21
  describe "#rule_for" do
22
22
  it "returns :one for English 1, :other for everything else" do
23
- Rules.rule_for(1, :en).should == :one
23
+ expect(Rules.rule_for(1, :en)).to eq(:one)
24
24
  [5, 9, 10, 20, 60, 99, 100, 103, 141].each do |num|
25
- Rules.rule_for(num, :en).should == :other
25
+ expect(Rules.rule_for(num, :en)).to eq(:other)
26
26
  end
27
27
  end
28
28
 
@@ -34,34 +34,34 @@ describe Rules do
34
34
  }
35
35
 
36
36
  rules.each do |rule, examples|
37
- examples.each { |n| Rules.rule_for(n, :ru).should == rule }
37
+ examples.each { |n| expect(Rules.rule_for(n, :ru)).to eq(rule) }
38
38
  end
39
39
  end
40
40
 
41
41
  it "returns :other if there's an error" do
42
42
  stub(Rules).get_resource { lambda { raise "Jelly beans" } }
43
- Rules.rule_for(1, :en).should == :other
44
- Rules.rule_for(1, :ru).should == :other
43
+ expect(Rules.rule_for(1, :en)).to eq(:other)
44
+ expect(Rules.rule_for(1, :ru)).to eq(:other)
45
45
  end
46
46
  end
47
47
 
48
48
  describe "#all_for" do
49
49
  it "returns a list of all applicable rules for the given locale" do
50
- Rules.all_for(:en).should =~ [:one, :other]
51
- Rules.all_for(:ru).should =~ [:one, :many, :other]
50
+ expect(Rules.all_for(:en)).to match_array([:one, :other])
51
+ expect(Rules.all_for(:ru)).to match_array([:one, :many, :other])
52
52
  end
53
53
 
54
54
  it "returns nil on error" do
55
55
  stub(Rules).get_resource { lambda { raise "Jelly beans" } }
56
- Rules.all_for(:en).should be_nil
57
- Rules.all_for(:ru).should be_nil
56
+ expect(Rules.all_for(:en)).to be_nil
57
+ expect(Rules.all_for(:ru)).to be_nil
58
58
  end
59
59
  end
60
60
 
61
61
  describe "#all" do
62
62
  it "gets rules for the default locale (usually supplied by FastGettext)" do
63
63
  mock(TwitterCldr).locale { :ru }
64
- Rules.all.should =~ [:one, :many, :other]
64
+ expect(Rules.all).to match_array([:one, :many, :other])
65
65
  end
66
66
  end
67
67
  end
@@ -10,7 +10,7 @@ include TwitterCldr::Localized
10
10
  describe LocalizedArray do
11
11
  describe '#code_points_to_string' do
12
12
  it 'transforms an array of code points into a string' do
13
- [0x74, 0x77, 0x69, 0x74, 0x74, 0x65, 0x72].localize.code_points_to_string.should == 'twitter'
13
+ expect([0x74, 0x77, 0x69, 0x74, 0x74, 0x65, 0x72].localize.code_points_to_string).to eq('twitter')
14
14
  end
15
15
  end
16
16
 
@@ -24,25 +24,25 @@ describe LocalizedArray do
24
24
 
25
25
  describe '#sort' do
26
26
  it 'returns a new LocalizedArray' do
27
- localized.sort.should be_instance_of(LocalizedArray)
27
+ expect(localized.sort).to be_instance_of(LocalizedArray)
28
28
  end
29
29
 
30
30
  it 'does not change the original array' do
31
- lambda { localized.sort }.should_not change { localized.base_obj }
31
+ expect { localized.sort }.not_to change { localized.base_obj }
32
32
  end
33
33
 
34
34
  it 'sorts strings in the array with corresponding collator' do
35
- localized.sort.base_obj.should == sorted
35
+ expect(localized.sort.base_obj).to eq(sorted)
36
36
  end
37
37
  end
38
38
 
39
39
  describe '#sort!' do
40
40
  it 'returns self' do
41
- localized.sort!.object_id.should == localized.object_id
41
+ expect(localized.sort!.object_id).to eq(localized.object_id)
42
42
  end
43
43
 
44
44
  it 'sorts the array in-place' do
45
- localized.sort!.base_obj.should == sorted
45
+ expect(localized.sort!.base_obj).to eq(sorted)
46
46
  end
47
47
  end
48
48
  end
@@ -53,14 +53,14 @@ describe LocalizedArray do
53
53
  index = 0
54
54
 
55
55
  arr.localize.each do |item|
56
- arr[index].should == item
56
+ expect(arr[index]).to eq(item)
57
57
  index += 1
58
58
  end
59
59
  end
60
60
 
61
61
  it "should support a few of the other methods in Enumerable" do
62
- [1, 2, 3].localize.inject(0) { |sum, num| sum += num; sum }.should == 6
63
- [1, 2, 3].localize.map { |item| item + 1 }.should == [2, 3, 4]
62
+ expect([1, 2, 3].localize.inject(0) { |sum, num| sum += num; sum }).to eq(6)
63
+ expect([1, 2, 3].localize.map { |item| item + 1 }).to eq([2, 3, 4])
64
64
  end
65
65
  end
66
66
 
@@ -69,9 +69,9 @@ describe LocalizedArray do
69
69
  arr = [:foo, "bar", Object.new]
70
70
  result = YAML.load(arr.localize.to_yaml)
71
71
 
72
- result[0].should == :foo
73
- result[1].should == "bar"
74
- result[2].should be_a(Object)
72
+ expect(result[0]).to eq(:foo)
73
+ expect(result[1]).to eq("bar")
74
+ expect(result[2]).to be_a(Object)
75
75
  end
76
76
  end
77
77
  end
@@ -18,45 +18,45 @@ describe LocalizedDate do
18
18
  it "should ago-ify from now when no base_time given" do
19
19
  stub(Time).now { Time.gm(2010, 8, 6, 12, 12, 30) }
20
20
  loc_date = date_time.localize(:ko).to_date
21
- loc_date.ago.to_s(:unit => :hour).should match_normalized("744시간 전")
21
+ expect(loc_date.ago.to_s(:unit => :hour)).to match_normalized("744시간 전")
22
22
  end
23
23
 
24
24
  it "should ago-ify with appropriate unit when no unit given" do
25
25
  loc_date = date_time.localize(:en).to_date
26
- loc_date.ago(:base_time => base_time).to_s.should match_normalized("1 month ago")
27
- loc_date.ago(:base_time => Time.gm(2010, 12, 6, 12, 12, 30)).to_s.should match_normalized("5 months ago")
28
- loc_date.ago(:base_time => Time.gm(2010, 7, 7, 12, 12, 30)).to_s.should match_normalized("1 day ago")
26
+ expect(loc_date.ago(:base_time => base_time).to_s).to match_normalized("1 month ago")
27
+ expect(loc_date.ago(:base_time => Time.gm(2010, 12, 6, 12, 12, 30)).to_s).to match_normalized("5 months ago")
28
+ expect(loc_date.ago(:base_time => Time.gm(2010, 7, 7, 12, 12, 30)).to_s).to match_normalized("1 day ago")
29
29
  end
30
30
 
31
31
  it "should ago-ify with strings regardless of variable's placement or existence" do
32
32
  loc_date = date_time.localize(:ar).to_date
33
- loc_date.ago(:base_time => base_time).to_s(:unit => :hour).should match_normalized("قبل 744 ساعة")
34
- loc_date.ago(:base_time => base_time).to_s(:unit => :day).should match_normalized("قبل 31 يومًا")
35
- loc_date.ago(:base_time => base_time).to_s(:unit => :month).should match_normalized("قبل 1 من الشهور")
36
- loc_date.ago(:base_time => base_time).to_s(:unit => :year).should match_normalized("قبل 0 من السنوات")
33
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :hour)).to match_normalized("قبل 744 ساعة")
34
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :day)).to match_normalized("قبل 31 يومًا")
35
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :month)).to match_normalized("قبل 1 من الشهور")
36
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :year)).to match_normalized("قبل 0 من السنوات")
37
37
 
38
38
  loc_date = date_time.localize(:fa).to_date
39
- loc_date.ago(:base_time => base_time).to_s(:unit => :day).should match_normalized("31 روز پیش")
39
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :day)).to match_normalized("31 روز پیش")
40
40
 
41
41
  loc_date = date_time.localize(:en).to_date
42
- loc_date.ago(:base_time => base_time).to_s(:unit => :day).should match_normalized("31 days ago")
42
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :day)).to match_normalized("31 days ago")
43
43
  end
44
44
 
45
45
  it "should ago-ify a date with a number of different units" do
46
46
  date_time = DateTime.new(2010, 6, 6, 12, 12, 30)
47
47
  loc_date = date_time.localize(:de).to_date
48
- loc_date.ago(:base_time => base_time).to_s(:unit => :second).should match_normalized("Vor 5270400 Sekunden")
49
- loc_date.ago(:base_time => base_time).to_s(:unit => :minute).should match_normalized("Vor 87840 Minuten")
50
- loc_date.ago(:base_time => base_time).to_s(:unit => :hour).should match_normalized("Vor 1464 Stunden")
51
- loc_date.ago(:base_time => base_time).to_s(:unit => :day).should match_normalized("Vor 61 Tagen")
52
- loc_date.ago(:base_time => base_time).to_s(:unit => :month).should match_normalized("Vor 2 Monaten")
53
- loc_date.ago(:base_time => base_time).to_s(:unit => :year).should match_normalized("Vor 0 Jahren")
48
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :second)).to match_normalized("Vor 5270400 Sekunden")
49
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :minute)).to match_normalized("Vor 87840 Minuten")
50
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :hour)).to match_normalized("Vor 1464 Stunden")
51
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :day)).to match_normalized("Vor 61 Tagen")
52
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :month)).to match_normalized("Vor 2 Monaten")
53
+ expect(loc_date.ago(:base_time => base_time).to_s(:unit => :year)).to match_normalized("Vor 0 Jahren")
54
54
  end
55
55
 
56
56
  it "should return an error if called on a date in the future" do
57
57
  date_time = DateTime.new(2010, 10, 10, 12, 12, 30)
58
58
  loc_date = date_time.localize(:de).to_date
59
- lambda { loc_date.ago(base_time, :second)}.should raise_error(ArgumentError)
59
+ expect { loc_date.ago(base_time, :second)}.to raise_error(ArgumentError)
60
60
  end
61
61
  end
62
62
 
@@ -66,18 +66,18 @@ describe LocalizedDate do
66
66
  it "should until-ify with a number of different units" do
67
67
  date_time = DateTime.new(2010, 10, 10, 12, 12, 30)
68
68
  loc_date = date_time.localize(:de).to_date
69
- loc_date.until(:base_time => base_time).to_s(:unit => :second).should match_normalized("In 5616000 Sekunden")
70
- loc_date.until(:base_time => base_time).to_s(:unit => :minute).should match_normalized("In 93600 Minuten")
71
- loc_date.until(:base_time => base_time).to_s(:unit => :hour).should match_normalized("In 1560 Stunden")
72
- loc_date.until(:base_time => base_time).to_s(:unit => :day).should match_normalized("In 65 Tagen")
73
- loc_date.until(:base_time => base_time).to_s(:unit => :month).should match_normalized("In 2 Monaten")
74
- loc_date.until(:base_time => base_time).to_s(:unit => :year).should match_normalized("In 0 Jahren")
69
+ expect(loc_date.until(:base_time => base_time).to_s(:unit => :second)).to match_normalized("In 5616000 Sekunden")
70
+ expect(loc_date.until(:base_time => base_time).to_s(:unit => :minute)).to match_normalized("In 93600 Minuten")
71
+ expect(loc_date.until(:base_time => base_time).to_s(:unit => :hour)).to match_normalized("In 1560 Stunden")
72
+ expect(loc_date.until(:base_time => base_time).to_s(:unit => :day)).to match_normalized("In 65 Tagen")
73
+ expect(loc_date.until(:base_time => base_time).to_s(:unit => :month)).to match_normalized("In 2 Monaten")
74
+ expect(loc_date.until(:base_time => base_time).to_s(:unit => :year)).to match_normalized("In 0 Jahren")
75
75
  end
76
76
 
77
77
  it "should return an error if called on a date in the past" do
78
78
  date_time = DateTime.new(2010, 4, 4, 12, 12, 30)
79
79
  loc_date = date_time.localize(:de).to_date
80
- lambda { loc_date.until(base_time, :second)}.should raise_error(ArgumentError)
80
+ expect { loc_date.until(base_time, :second)}.to raise_error(ArgumentError)
81
81
  end
82
82
  end
83
83
 
@@ -91,7 +91,7 @@ describe LocalizedDate do
91
91
 
92
92
  it "should stringify with buddhist calendar" do
93
93
  # Ensure that buddhist calendar data is present in th locale.
94
- TwitterCldr.get_locale_resource(:th, :calendars)[:th][:calendars][:buddhist].should_not(
94
+ expect(TwitterCldr.get_locale_resource(:th, :calendars)[:th][:calendars][:buddhist]).not_to(
95
95
  be_nil, 'buddhist calendar is missing for :th locale (check resources/locales/th/calendars.yml)'
96
96
  )
97
97
 
@@ -107,16 +107,16 @@ describe LocalizedDate do
107
107
  date_time = DateTime.new(1987, 9, 20, 0, 0, 0)
108
108
  time = Time.local(2000, 5, 12, 22, 5)
109
109
  datetime = date_time.localize.to_date.to_datetime(time)
110
- datetime.should be_a(LocalizedDateTime)
111
- datetime.base_obj.strftime("%Y-%m-%d %H:%M:%S").should == "1987-09-20 22:05:00"
110
+ expect(datetime).to be_a(LocalizedDateTime)
111
+ expect(datetime.base_obj.strftime("%Y-%m-%d %H:%M:%S")).to eq("1987-09-20 22:05:00")
112
112
  end
113
113
 
114
114
  it "should work with an instance of LocalizedTime too" do
115
115
  date_time = DateTime.new(1987, 9, 20, 0, 0, 0)
116
116
  time = Time.local(2000, 5, 12, 22, 5).localize
117
117
  datetime = date_time.localize.to_date.to_datetime(time)
118
- datetime.should be_a(LocalizedDateTime)
119
- datetime.base_obj.strftime("%Y-%m-%d %H:%M:%S").should == "1987-09-20 22:05:00"
118
+ expect(datetime).to be_a(LocalizedDateTime)
119
+ expect(datetime.base_obj.strftime("%Y-%m-%d %H:%M:%S")).to eq("1987-09-20 22:05:00")
120
120
  end
121
121
  end
122
122
 
@@ -124,7 +124,7 @@ describe LocalizedDate do
124
124
  it "don't raise errors for any locale" do
125
125
  TwitterCldr.supported_locales.each do |locale|
126
126
  (LocalizedDate.types - [:additional]).each do |type|
127
- lambda { DateTime.now.localize(locale).to_date.send(:"to_#{type}_s") }.should_not raise_error
127
+ expect { DateTime.now.localize(locale).to_date.send(:"to_#{type}_s") }.not_to raise_error
128
128
  end
129
129
  end
130
130
  end
@@ -133,9 +133,9 @@ describe LocalizedDate do
133
133
  describe "#with_timezone" do
134
134
  it "calculates the right day depending on the timezone" do
135
135
  loc_date = DateTime.new(1987, 9, 20, 0, 0, 0).localize.to_date
136
- loc_date.to_s.should == "Sep 20, 1987"
137
- loc_date.with_timezone("America/Los_Angeles").to_s.should == "Sep 19, 1987"
138
- loc_date.with_timezone("Asia/Tokyo").to_s.should == "Sep 20, 1987"
136
+ expect(loc_date.to_s).to eq("Sep 20, 1987")
137
+ expect(loc_date.with_timezone("America/Los_Angeles").to_s).to eq("Sep 19, 1987")
138
+ expect(loc_date.with_timezone("Asia/Tokyo").to_s).to eq("Sep 20, 1987")
139
139
  end
140
140
  end
141
141
 
@@ -13,11 +13,11 @@ describe LocalizedDateTime do
13
13
 
14
14
  describe '#initilize' do
15
15
  it 'sets calendar type' do
16
- date_time.localize(:th, :calendar_type => :buddhist).calendar_type.should == :buddhist
16
+ expect(date_time.localize(:th, :calendar_type => :buddhist).calendar_type).to eq(:buddhist)
17
17
  end
18
18
 
19
19
  it 'uses default calendar type' do
20
- date_time.localize(:en).calendar_type.should == TwitterCldr::DEFAULT_CALENDAR_TYPE
20
+ expect(date_time.localize(:en).calendar_type).to eq(TwitterCldr::DEFAULT_CALENDAR_TYPE)
21
21
  end
22
22
  end
23
23
 
@@ -31,7 +31,7 @@ describe LocalizedDateTime do
31
31
 
32
32
  it "should stringify with buddhist calendar" do
33
33
  # Ensure that buddhist calendar data is present in th locale.
34
- TwitterCldr.get_locale_resource(:th, :calendars)[:th][:calendars][:buddhist].should_not(
34
+ expect(TwitterCldr.get_locale_resource(:th, :calendars)[:th][:calendars][:buddhist]).not_to(
35
35
  be_nil, 'buddhist calendar is missing for :th locale (check resources/locales/th/calendars.yml)'
36
36
  )
37
37
 
@@ -44,7 +44,7 @@ describe LocalizedDateTime do
44
44
 
45
45
  describe "#to_date" do
46
46
  it "should convert to a date" do
47
- date_time.localize.to_date.base_obj.strftime("%Y-%m-%d").should == "1987-09-20"
47
+ expect(date_time.localize.to_date.base_obj.strftime("%Y-%m-%d")).to eq("1987-09-20")
48
48
  end
49
49
 
50
50
  it 'forwards calendar type' do
@@ -54,7 +54,7 @@ describe LocalizedDateTime do
54
54
 
55
55
  describe "#to_time" do
56
56
  it "should convert to a time" do
57
- date_time.localize.to_time.base_obj.getgm.strftime("%H:%M:%S").should == "22:05:00"
57
+ expect(date_time.localize.to_time.base_obj.getgm.strftime("%H:%M:%S")).to eq("22:05:00")
58
58
  end
59
59
 
60
60
  it 'forwards calendar type' do
@@ -64,7 +64,7 @@ describe LocalizedDateTime do
64
64
 
65
65
  describe "#to_timespan" do
66
66
  it "should return a localized timespan" do
67
- date_time.localize.to_timespan.should be_a(LocalizedTimespan)
67
+ expect(date_time.localize.to_timespan).to be_a(LocalizedTimespan)
68
68
  end
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ describe LocalizedDateTime do
72
72
  it "don't raise errors for any locale" do
73
73
  TwitterCldr.supported_locales.each do |locale|
74
74
  (TwitterCldr::DataReaders::CalendarDataReader.types - [:additional]).each do |type|
75
- lambda { date_time.localize(locale).send(:"to_#{type}_s") }.should_not raise_error
75
+ expect { date_time.localize(locale).send(:"to_#{type}_s") }.not_to raise_error
76
76
  end
77
77
  end
78
78
  end
@@ -93,16 +93,16 @@ describe LocalizedDateTime do
93
93
  it "uses the default format if no :format is given" do
94
94
  loc_date = date_time.localize
95
95
  mock.proxy(loc_date).to_default_s
96
- loc_date.to_s.should == "Sep 20, 1987, 10:05:00 PM"
96
+ expect(loc_date.to_s).to eq("Sep 20, 1987, 10:05:00 PM")
97
97
  end
98
98
  end
99
99
 
100
100
  describe "#with_timezone" do
101
101
  it "calculates the right time depending on the timezone" do
102
102
  loc_date = date_time.localize
103
- loc_date.to_s.should == "Sep 20, 1987, 10:05:00 PM"
104
- loc_date.with_timezone("America/Los_Angeles").to_s.should == "Sep 20, 1987, 3:05:00 PM"
105
- loc_date.with_timezone("America/New_York").to_s.should == "Sep 20, 1987, 6:05:00 PM"
103
+ expect(loc_date.to_s).to eq("Sep 20, 1987, 10:05:00 PM")
104
+ expect(loc_date.with_timezone("America/Los_Angeles").to_s).to eq("Sep 20, 1987, 3:05:00 PM")
105
+ expect(loc_date.with_timezone("America/New_York").to_s).to eq("Sep 20, 1987, 6:05:00 PM")
106
106
  end
107
107
  end
108
108
 
@@ -13,10 +13,10 @@ describe LocalizedHash do
13
13
  hash = { :foo => "bar", "string_key" => Object.new }
14
14
  result = YAML.load(hash.localize.to_yaml)
15
15
 
16
- result.should include(:foo)
17
- result.should include("string_key")
18
- result[:foo].should == "bar"
19
- result["string_key"].should be_a(Object)
16
+ expect(result).to include(:foo)
17
+ expect(result).to include("string_key")
18
+ expect(result[:foo]).to eq("bar")
19
+ expect(result["string_key"]).to be_a(Object)
20
20
  end
21
21
  end
22
22
  end