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
@@ -10,13 +10,13 @@ include TwitterCldr::Shared
10
10
  describe Casefolder do
11
11
  describe "#casefold" do
12
12
  it "should casefold a few canonical examples" do
13
- Casefolder.casefold("Weißrussland").should == "weissrussland"
14
- Casefolder.casefold("Hello, World").should == "hello, world"
13
+ expect(Casefolder.casefold("Weißrussland")).to eq("weissrussland")
14
+ expect(Casefolder.casefold("Hello, World")).to eq("hello, world")
15
15
  end
16
16
 
17
17
  it "should correctly casefold the Turkic i character" do
18
- Casefolder.casefold("Istanbul", true).should == "ıstanbul"
19
- Casefolder.casefold("İstanbul", true).should == "istanbul"
18
+ expect(Casefolder.casefold("Istanbul", true)).to eq("ıstanbul")
19
+ expect(Casefolder.casefold("İstanbul", true)).to eq("istanbul")
20
20
  end
21
21
 
22
22
  # the files used in this test come from the unicode_utils gem
@@ -24,7 +24,7 @@ describe Casefolder do
24
24
  base_path = File.dirname(__FILE__)
25
25
  text = File.read(File.join(base_path, "casefolding.txt"))
26
26
  expected = File.read(File.join(base_path, "casefolding_expected.txt"))
27
- Casefolder.casefold(text).should == expected
27
+ expect(Casefolder.casefold(text)).to eq(expected)
28
28
  end
29
29
  end
30
30
  end
@@ -26,15 +26,15 @@ describe CodePoint do
26
26
  let(:decomposition) { '0028 007A 0029' }
27
27
 
28
28
  it 'parses decomposition mapping' do
29
- code_point.decomposition.should == [0x28, 0x7A, 0x29]
29
+ expect(code_point.decomposition).to eq([0x28, 0x7A, 0x29])
30
30
  end
31
31
 
32
32
  it 'initializes compatibility tag as nil' do
33
- code_point.compatibility_decomposition_tag.should be_nil
33
+ expect(code_point.compatibility_decomposition_tag).to be_nil
34
34
  end
35
35
 
36
36
  it 'returns false from compatibility_decomposition?' do
37
- code_point.should_not be_compatibility_decomposition
37
+ expect(code_point).not_to be_compatibility_decomposition
38
38
  end
39
39
  end
40
40
 
@@ -42,15 +42,15 @@ describe CodePoint do
42
42
  let(:decomposition) { '<font> 0028 007A 0029' }
43
43
 
44
44
  it 'parses decomposition mapping' do
45
- code_point.decomposition.should == [0x28, 0x7A, 0x29]
45
+ expect(code_point.decomposition).to eq([0x28, 0x7A, 0x29])
46
46
  end
47
47
 
48
48
  it 'initializes compatibility decomposition tag' do
49
- code_point.compatibility_decomposition_tag.should == 'font'
49
+ expect(code_point.compatibility_decomposition_tag).to eq('font')
50
50
  end
51
51
 
52
52
  it 'returns true from compatibility_decomposition?' do
53
- code_point.should be_compatibility_decomposition
53
+ expect(code_point).to be_compatibility_decomposition
54
54
  end
55
55
  end
56
56
 
@@ -58,15 +58,15 @@ describe CodePoint do
58
58
  let(:decomposition) { '' }
59
59
 
60
60
  it 'parses decomposition mapping' do
61
- code_point.decomposition.should be_nil
61
+ expect(code_point.decomposition).to be_nil
62
62
  end
63
63
 
64
64
  it 'initializes compatibility tag as nil' do
65
- code_point.compatibility_decomposition_tag.should be_nil
65
+ expect(code_point.compatibility_decomposition_tag).to be_nil
66
66
  end
67
67
 
68
68
  it 'returns false from compatibility_decomposition?' do
69
- code_point.should_not be_compatibility_decomposition
69
+ expect(code_point).not_to be_compatibility_decomposition
70
70
  end
71
71
  end
72
72
  end
@@ -74,12 +74,12 @@ describe CodePoint do
74
74
  describe "#find" do
75
75
  it "retrieves information for any valid code point" do
76
76
  data = CodePoint.find(0x301)
77
- data.should be_a(CodePoint)
78
- data.fields.length.should == 15
77
+ expect(data).to be_a(CodePoint)
78
+ expect(data.fields.length).to eq(15)
79
79
  end
80
80
 
81
81
  it "returns nil if the information is not found" do
82
- CodePoint.find(0xFFFFFFF).should be_nil
82
+ expect(CodePoint.find(0xFFFFFFF)).to be_nil
83
83
  end
84
84
 
85
85
  it "fetches valid information for the specified code point" do
@@ -106,9 +106,9 @@ describe CodePoint do
106
106
  test_data.each do |code_point, data|
107
107
  cp_data = CodePoint.find(code_point)
108
108
 
109
- cp_data.should_not be_nil
109
+ expect(cp_data).not_to be_nil
110
110
 
111
- [:code_point, :name, :category, :combining_class].map { |msg| cp_data.send(msg) }.should == data[0..3]
111
+ expect([:code_point, :name, :category, :combining_class].map { |msg| cp_data.send(msg) }).to eq(data[0..3])
112
112
  end
113
113
  end
114
114
  end
@@ -116,32 +116,32 @@ describe CodePoint do
116
116
  describe "#code_points_for{index}" do
117
117
  it "returns code points for the given general unicode property name" do
118
118
  cps = CodePoint.code_points_for_category(:Cc)
119
- cps.should be_a(Array)
120
- cps.first.should == (0..31)
119
+ expect(cps).to be_a(Array)
120
+ expect(cps.first).to eq(0..31)
121
121
 
122
122
  cps = CodePoint.code_points_for_bidi_class(:BN)
123
- cps.should be_a(Array)
124
- cps.first.should == (0..8)
123
+ expect(cps).to be_a(Array)
124
+ expect(cps.first).to eq(0..8)
125
125
 
126
126
  cps = CodePoint.code_points_for_bidi_mirrored(:N)
127
- cps.should be_a(Array)
128
- cps.first.should == (0..39)
127
+ expect(cps).to be_a(Array)
128
+ expect(cps.first).to eq(0..39)
129
129
  end
130
130
  end
131
131
 
132
132
  describe "#code_points_for_property_value" do
133
133
  it "returns code points for the given unicode property and value" do
134
134
  cps = CodePoint.code_points_for_line_break(:CM)
135
- cps.should be_a(Array)
136
- cps.first.should == (0..8)
135
+ expect(cps).to be_a(Array)
136
+ expect(cps.first).to eq(0..8)
137
137
 
138
138
  cps = CodePoint.code_points_for_sentence_break(:Extend)
139
- cps.should be_a(Array)
140
- cps.first.should == (768..879)
139
+ expect(cps).to be_a(Array)
140
+ expect(cps.first).to eq(768..879)
141
141
 
142
142
  cps = CodePoint.code_points_for_word_break(:Hebrew_Letter)
143
- cps.should be_a(Array)
144
- cps.first.should == (1488..1514)
143
+ expect(cps).to be_a(Array)
144
+ expect(cps.first).to eq(1488..1514)
145
145
  end
146
146
  end
147
147
 
@@ -158,18 +158,18 @@ describe CodePoint do
158
158
  end
159
159
 
160
160
  it "should return a code point with the correct value" do
161
- CodePoint.for_canonical_decomposition([123, 456]).should == "I'm code point 789"
161
+ expect(CodePoint.for_canonical_decomposition([123, 456])).to eq("I'm code point 789")
162
162
  end
163
163
 
164
164
  it "should return nil if no decomposition mapping exists" do
165
- CodePoint.for_canonical_decomposition([987]).should be_nil
165
+ expect(CodePoint.for_canonical_decomposition([987])).to be_nil
166
166
  end
167
167
  end
168
168
 
169
169
  it "should cache the decomposition map" do
170
170
  mock(TwitterCldr).get_resource(:unicode_data, :canonical_compositions) { canonical_compositions }.once
171
- CodePoint.for_canonical_decomposition([0xA0]).should be_nil
172
- CodePoint.for_canonical_decomposition([0xA0]).should be_nil
171
+ expect(CodePoint.for_canonical_decomposition([0xA0])).to be_nil
172
+ expect(CodePoint.for_canonical_decomposition([0xA0])).to be_nil
173
173
  end
174
174
  end
175
175
 
@@ -186,29 +186,29 @@ describe CodePoint do
186
186
  end
187
187
 
188
188
  it "returns nil if not part of a hangul block" do
189
- CodePoint.hangul_type(100).should == nil
189
+ expect(CodePoint.hangul_type(100)).to eq(nil)
190
190
  end
191
191
 
192
192
  it "returns the correct part (i.e. lpart, vpart, or tpart) before composition or decomposition" do
193
- CodePoint.hangul_type(5).should == :lparts
194
- CodePoint.hangul_type(30).should == :vparts
195
- CodePoint.hangul_type(41).should == :tparts
193
+ expect(CodePoint.hangul_type(5)).to eq(:lparts)
194
+ expect(CodePoint.hangul_type(30)).to eq(:vparts)
195
+ expect(CodePoint.hangul_type(41)).to eq(:tparts)
196
196
  end
197
197
 
198
198
  it "returns composition if no part can be found" do
199
- CodePoint.hangul_type(11).should == :compositions
199
+ expect(CodePoint.hangul_type(11)).to eq(:compositions)
200
200
  end
201
201
  end
202
202
 
203
203
  describe "#excluded_from_composition?" do
204
204
  it "excludes anything in the list of ranges" do
205
205
  stub(CodePoint).composition_exclusions { [10..10, 13..14, 20..30] }
206
- CodePoint.excluded_from_composition?(10).should be_true
207
- CodePoint.excluded_from_composition?(13).should be_true
208
- CodePoint.excluded_from_composition?(14).should be_true
209
- CodePoint.excluded_from_composition?(15).should be_false
210
- CodePoint.excluded_from_composition?(19).should be_false
211
- CodePoint.excluded_from_composition?(100).should be_false
206
+ expect(CodePoint.excluded_from_composition?(10)).to be_true
207
+ expect(CodePoint.excluded_from_composition?(13)).to be_true
208
+ expect(CodePoint.excluded_from_composition?(14)).to be_true
209
+ expect(CodePoint.excluded_from_composition?(15)).to be_false
210
+ expect(CodePoint.excluded_from_composition?(19)).to be_false
211
+ expect(CodePoint.excluded_from_composition?(100)).to be_false
212
212
  end
213
213
  end
214
214
 
@@ -219,21 +219,21 @@ describe CodePoint do
219
219
 
220
220
  it "finds the block that corresponds to the code point" do
221
221
  stub(TwitterCldr).get_resource(:unicode_data, :blocks) { [[:klingon, 122..307], [:hirogen, 1337..2200]] }
222
- CodePoint.send(:get_block, 200).should == [:klingon, 122..307]
223
- CodePoint.send(:get_block, 2199).should == [:hirogen, 1337..2200]
224
- CodePoint.send(:get_block, 100).should be_nil
222
+ expect(CodePoint.send(:get_block, 200)).to eq([:klingon, 122..307])
223
+ expect(CodePoint.send(:get_block, 2199)).to eq([:hirogen, 1337..2200])
224
+ expect(CodePoint.send(:get_block, 100)).to be_nil
225
225
  end
226
226
  end
227
227
 
228
228
  describe "#get_range_start" do
229
229
  it "returns the data for a non-explicit range" do
230
230
  block_data = { 0x1337 => [0x1337, "<CJK Ideograph Extension A, First>"] }
231
- CodePoint.send(:get_range_start, 0xABC, block_data).should == [0xABC, "<CJK Ideograph Extension A>"]
231
+ expect(CodePoint.send(:get_range_start, 0xABC, block_data)).to eq([0xABC, "<CJK Ideograph Extension A>"])
232
232
  end
233
233
 
234
234
  it "returns nil if the block data doesn't contain a non-explicit range" do
235
235
  block_data = { 0x1337 => [0x1337, "<CJK Ideograph Extension A>"] }
236
- CodePoint.send(:get_range_start, 0xABC, block_data).should == nil
236
+ expect(CodePoint.send(:get_range_start, 0xABC, block_data)).to eq(nil)
237
237
  end
238
238
  end
239
239
  end
@@ -15,16 +15,16 @@ describe Currencies do
15
15
  it "should list all supported country codes" do
16
16
  codes = Currencies.currency_codes
17
17
 
18
- codes.size.should == 297
19
- codes.should include(*TEST_CODES)
18
+ expect(codes.size).to eq(297)
19
+ expect(codes).to include(*TEST_CODES)
20
20
  end
21
21
  end
22
22
 
23
23
  describe "#for_code" do
24
24
  it "should return all information for PEN" do
25
25
  data = Currencies.for_code("PEN")
26
- data.should be_a(Hash)
27
- data.should include(
26
+ expect(data).to be_a(Hash)
27
+ expect(data).to include(
28
28
  :name => "Peruvian nuevo sol",
29
29
  :currency => :PEN,
30
30
  :symbol => "S/.",
@@ -34,8 +34,8 @@ describe Currencies do
34
34
 
35
35
  it "should return all information for CAD, a currency code with multiple possible symbols" do
36
36
  data = Currencies.for_code("CAD")
37
- data.should be_a(Hash)
38
- data.should include(
37
+ expect(data).to be_a(Hash)
38
+ expect(data).to include(
39
39
  :name => "Canadian dollar",
40
40
  :currency => :CAD,
41
41
  :symbol => "$",
@@ -46,7 +46,7 @@ describe Currencies do
46
46
  it "verifies that all code_points values are equivalent to their corresponding symbols" do
47
47
  Currencies.currency_codes.select do |code|
48
48
  data = Currencies.for_code(code)
49
- data[:code_points].pack("U*").should == data[:symbol]
49
+ expect(data[:code_points].pack("U*")).to eq(data[:symbol])
50
50
  end
51
51
  end
52
52
  end
@@ -12,79 +12,79 @@ describe LanguageCodes do
12
12
  let(:languages) { LanguageCodes.languages }
13
13
 
14
14
  it 'returns an array' do
15
- languages.should be_instance_of(Array)
15
+ expect(languages).to be_instance_of(Array)
16
16
  end
17
17
 
18
18
  it 'returns symbols' do
19
- languages.each { |language| language.should be_instance_of(Symbol) }
19
+ languages.each { |language| expect(language).to be_instance_of(Symbol) }
20
20
  end
21
21
 
22
22
  it 'returns supported languages' do
23
- languages.should include(:Spanish, :English, :Russian, :Japanese, :Basque)
23
+ expect(languages).to include(:Spanish, :English, :Russian, :Japanese, :Basque)
24
24
  end
25
25
  end
26
26
 
27
27
  describe '#valid_standard?' do
28
28
  it 'returns true if the standard is valid' do
29
- LanguageCodes.valid_standard?(:iso_639_2).should be_true
29
+ expect(LanguageCodes.valid_standard?(:iso_639_2)).to be_true
30
30
  end
31
31
 
32
32
  it 'returns false if the standard is invalid' do
33
- LanguageCodes.valid_standard?(:iso_639).should be_false
33
+ expect(LanguageCodes.valid_standard?(:iso_639)).to be_false
34
34
  end
35
35
 
36
36
  it 'accepts a string' do
37
- LanguageCodes.valid_standard?('iso_639_2').should be_true
37
+ expect(LanguageCodes.valid_standard?('iso_639_2')).to be_true
38
38
  end
39
39
  end
40
40
 
41
41
  describe '#valid_code?' do
42
42
  it 'returns true if the code is present in the given standard' do
43
- LanguageCodes.valid_code?(:spa, :iso_639_2).should be_true
43
+ expect(LanguageCodes.valid_code?(:spa, :iso_639_2)).to be_true
44
44
  end
45
45
 
46
46
  it 'returns false if the code is not present in the given standard' do
47
- LanguageCodes.valid_code?(:foo, :iso_639_2).should be_false
47
+ expect(LanguageCodes.valid_code?(:foo, :iso_639_2)).to be_false
48
48
  end
49
49
 
50
50
  it 'raises exception if the standard is invalid' do
51
- lambda { LanguageCodes.valid_code?(:es, :foobar) }.should raise_exception(ArgumentError, ':foobar is not a valid standard name')
51
+ expect { LanguageCodes.valid_code?(:es, :foobar) }.to raise_exception(ArgumentError, ':foobar is not a valid standard name')
52
52
  end
53
53
 
54
54
  it 'accepts strings' do
55
- LanguageCodes.valid_code?('spa', 'iso_639_2').should be_true
55
+ expect(LanguageCodes.valid_code?('spa', 'iso_639_2')).to be_true
56
56
  end
57
57
  end
58
58
 
59
59
  describe '#convert' do
60
60
  it 'converts codes between different standards' do
61
- LanguageCodes.convert(:Spanish, :from => :name, :to => :bcp_47 ).should == :es
62
- LanguageCodes.convert(:es, :from => :bcp_47, :to => :iso_639_1).should == :es
63
- LanguageCodes.convert(:es, :from => :iso_639_1, :to => :iso_639_2).should == :spa
64
- LanguageCodes.convert(:spa, :from => :iso_639_2, :to => :iso_639_3).should == :spa
65
- LanguageCodes.convert(:spa, :from => :iso_639_3, :to => :name ).should == :Spanish
61
+ expect(LanguageCodes.convert(:Spanish, :from => :name, :to => :bcp_47 )).to eq(:es)
62
+ expect(LanguageCodes.convert(:es, :from => :bcp_47, :to => :iso_639_1)).to eq(:es)
63
+ expect(LanguageCodes.convert(:es, :from => :iso_639_1, :to => :iso_639_2)).to eq(:spa)
64
+ expect(LanguageCodes.convert(:spa, :from => :iso_639_2, :to => :iso_639_3)).to eq(:spa)
65
+ expect(LanguageCodes.convert(:spa, :from => :iso_639_3, :to => :name )).to eq(:Spanish)
66
66
  end
67
67
 
68
68
  it 'converts from terminology iso_639_2 codes' do
69
- LanguageCodes.convert(:hye, :from => :iso_639_2, :to => :bcp_47).should == :hy
69
+ expect(LanguageCodes.convert(:hye, :from => :iso_639_2, :to => :bcp_47)).to eq(:hy)
70
70
  end
71
71
 
72
72
  it 'converts from alternative bcp_47 codes' do
73
- LanguageCodes.convert('ar-adf', :from => :bcp_47, :to => :iso_639_3).should == :adf
73
+ expect(LanguageCodes.convert('ar-adf', :from => :bcp_47, :to => :iso_639_3)).to eq(:adf)
74
74
  end
75
75
 
76
76
  it 'returns nil if conversion data is missing' do
77
- LanguageCodes.convert(:bsq, :from => :bcp_47, :to => :iso_639_1).should be_nil
78
- LanguageCodes.convert(:FooBar, :from => :name, :to => :iso_639_1).should be_nil
77
+ expect(LanguageCodes.convert(:bsq, :from => :bcp_47, :to => :iso_639_1)).to be_nil
78
+ expect(LanguageCodes.convert(:FooBar, :from => :name, :to => :iso_639_1)).to be_nil
79
79
  end
80
80
 
81
81
  it 'accepts strings' do
82
- LanguageCodes.convert('Spanish', 'from' => 'name', 'to' => 'bcp_47').should == :es
82
+ expect(LanguageCodes.convert('Spanish', 'from' => 'name', 'to' => 'bcp_47')).to eq(:es)
83
83
  end
84
84
 
85
85
  it 'raises exception if :from or :to options are missing' do
86
86
  [[:es, { :to => :bcp_47 }], [:es, { :from => :bcp_47 }], [:es]].each do |args|
87
- lambda { LanguageCodes.convert(*args) }.should raise_exception(ArgumentError, "options :from and :to are required")
87
+ expect { LanguageCodes.convert(*args) }.to raise_exception(ArgumentError, "options :from and :to are required")
88
88
  end
89
89
  end
90
90
 
@@ -94,36 +94,36 @@ describe LanguageCodes do
94
94
  [:es, { :from => :bcp_47, :to => :foobar }],
95
95
  [:es, { :from => :foobar, :to => :foobar }]
96
96
  ].each do |args|
97
- lambda { LanguageCodes.convert(*args) }.should raise_exception(ArgumentError, ':foobar is not a valid standard name')
97
+ expect { LanguageCodes.convert(*args) }.to raise_exception(ArgumentError, ':foobar is not a valid standard name')
98
98
  end
99
99
  end
100
100
  end
101
101
 
102
102
  describe '#from_language' do
103
103
  it 'returns language code by language name' do
104
- LanguageCodes.from_language(:Spanish, :iso_639_2).should == :spa
104
+ expect(LanguageCodes.from_language(:Spanish, :iso_639_2)).to eq(:spa)
105
105
  end
106
106
 
107
107
  it 'accepts strings' do
108
- LanguageCodes.from_language('Spanish', 'iso_639_2').should == :spa
108
+ expect(LanguageCodes.from_language('Spanish', 'iso_639_2')).to eq(:spa)
109
109
  end
110
110
 
111
111
  it 'raises exception when standard is invalid' do
112
- lambda { LanguageCodes.from_language(:Spanish, :foobar) }.should raise_exception(':foobar is not a valid standard name')
112
+ expect { LanguageCodes.from_language(:Spanish, :foobar) }.to raise_exception(':foobar is not a valid standard name')
113
113
  end
114
114
  end
115
115
 
116
116
  describe '#to_language' do
117
117
  it 'returns language name as a string by language code' do
118
- LanguageCodes.to_language(:es, :iso_639_1).should == 'Spanish'
118
+ expect(LanguageCodes.to_language(:es, :iso_639_1)).to eq('Spanish')
119
119
  end
120
120
 
121
121
  it 'accepts strings' do
122
- LanguageCodes.to_language('es', 'iso_639_1').should == 'Spanish'
122
+ expect(LanguageCodes.to_language('es', 'iso_639_1')).to eq('Spanish')
123
123
  end
124
124
 
125
125
  it 'raises exception when standard is invalid' do
126
- lambda { LanguageCodes.to_language(:es, :foobar) }.should raise_exception(':foobar is not a valid standard name')
126
+ expect { LanguageCodes.to_language(:es, :foobar) }.to raise_exception(':foobar is not a valid standard name')
127
127
  end
128
128
  end
129
129
 
@@ -131,15 +131,15 @@ describe LanguageCodes do
131
131
  let(:spanish_standards) { [:bcp_47, :iso_639_1, :iso_639_2, :iso_639_3] }
132
132
 
133
133
  it 'returns an array of standards that are available for conversion from a given code' do
134
- LanguageCodes.standards_for(:es, :bcp_47).should =~ spanish_standards
134
+ expect(LanguageCodes.standards_for(:es, :bcp_47)).to match_array(spanish_standards)
135
135
  end
136
136
 
137
137
  it 'accepts string' do
138
- LanguageCodes.standards_for('es', 'bcp_47').should =~ spanish_standards
138
+ expect(LanguageCodes.standards_for('es', 'bcp_47')).to match_array(spanish_standards)
139
139
  end
140
140
 
141
141
  it 'raises exception when standard is invalid' do
142
- lambda { LanguageCodes.standards_for(:es, :foobar) }.should raise_exception(':foobar is not a valid standard name')
142
+ expect { LanguageCodes.standards_for(:es, :foobar) }.to raise_exception(':foobar is not a valid standard name')
143
143
  end
144
144
  end
145
145
 
@@ -147,15 +147,15 @@ describe LanguageCodes do
147
147
  let(:spanish_standards) { [:bcp_47, :iso_639_1, :iso_639_2, :iso_639_3] }
148
148
 
149
149
  it 'returns an array of standards that have a code for a given language' do
150
- LanguageCodes.standards_for_language(:Spanish).should =~ spanish_standards
150
+ expect(LanguageCodes.standards_for_language(:Spanish)).to match_array(spanish_standards)
151
151
  end
152
152
 
153
153
  it 'accepts string' do
154
- LanguageCodes.standards_for_language('Spanish').should =~ spanish_standards
154
+ expect(LanguageCodes.standards_for_language('Spanish')).to match_array(spanish_standards)
155
155
  end
156
156
 
157
157
  it 'returns empty array for unknown languages' do
158
- LanguageCodes.standards_for_language('FooBar').should == []
158
+ expect(LanguageCodes.standards_for_language('FooBar')).to eq([])
159
159
  end
160
160
  end
161
161
  end
@@ -10,98 +10,98 @@ include TwitterCldr::Shared
10
10
  describe Languages do
11
11
  describe "#translate_language" do
12
12
  it "should translate a language from one locale to another" do
13
- Languages.translate_language("Russian", :en, :es).should match_normalized("ruso")
14
- Languages.translate_language("ruso", :es, :en).should match_normalized("Russian")
15
- Languages.translate_language("Spanish", :en, :es).should match_normalized("español")
16
- Languages.translate_language("ruso", :es, :ru).should match_normalized("русский")
13
+ expect(Languages.translate_language("Russian", :en, :es)).to match_normalized("ruso")
14
+ expect(Languages.translate_language("ruso", :es, :en)).to match_normalized("Russian")
15
+ expect(Languages.translate_language("Spanish", :en, :es)).to match_normalized("español")
16
+ expect(Languages.translate_language("ruso", :es, :ru)).to match_normalized("русский")
17
17
  end
18
18
 
19
19
  it "should be capitalization agnostic" do
20
- Languages.translate_language("russian", :en, :es).should match_normalized("ruso")
21
- Languages.translate_language("RUSSIAN", :en, :es).should match_normalized("ruso")
20
+ expect(Languages.translate_language("russian", :en, :es)).to match_normalized("ruso")
21
+ expect(Languages.translate_language("RUSSIAN", :en, :es)).to match_normalized("ruso")
22
22
  end
23
23
 
24
24
  it "defaults the destination language to English (or whatever the global locale is)" do
25
- Languages.translate_language("Ruso", :es).should match_normalized("Russian")
26
- Languages.translate_language("русский", :ru).should match_normalized("Russian")
25
+ expect(Languages.translate_language("Ruso", :es)).to match_normalized("Russian")
26
+ expect(Languages.translate_language("русский", :ru)).to match_normalized("Russian")
27
27
  end
28
28
 
29
29
  it "defaults source and destination language to English if not given" do
30
- Languages.translate_language("Russian").should match_normalized("Russian")
30
+ expect(Languages.translate_language("Russian")).to match_normalized("Russian")
31
31
  TwitterCldr.locale = :es
32
- Languages.translate_language("Russian").should match_normalized("ruso")
32
+ expect(Languages.translate_language("Russian")).to match_normalized("ruso")
33
33
  end
34
34
 
35
35
  it "successfully translates locale codes that are and are not in the CLDR using the locale map" do
36
- Languages.translate_language("Russian", :en, :'zh-cn').should match_normalized("俄文")
37
- Languages.translate_language("Russian", :en, :'zh').should match_normalized("俄文")
36
+ expect(Languages.translate_language("Russian", :en, :'zh-cn')).to match_normalized("俄文")
37
+ expect(Languages.translate_language("Russian", :en, :'zh')).to match_normalized("俄文")
38
38
  end
39
39
 
40
40
  it "should return nil if no translation was found" do
41
- Languages.translate_language("Russian", :en, :blarg).should == nil
41
+ expect(Languages.translate_language("Russian", :en, :blarg)).to eq(nil)
42
42
  end
43
43
  end
44
44
 
45
45
  describe "#from_code_for_locale" do
46
46
  it "should return the language in the correct locale for the given locale code (i.e. es in English should be Spanish)" do
47
- Languages.from_code_for_locale(:es, :en).should match_normalized("Spanish")
48
- Languages.from_code_for_locale(:en, :es).should match_normalized("inglés")
47
+ expect(Languages.from_code_for_locale(:es, :en)).to match_normalized("Spanish")
48
+ expect(Languages.from_code_for_locale(:en, :es)).to match_normalized("inglés")
49
49
  end
50
50
  end
51
51
 
52
52
  describe "#from_code" do
53
53
  it "should return the language in the default locale for the given locale code" do
54
- Languages.from_code(:es).should match_normalized("Spanish")
55
- Languages.from_code(:ru).should match_normalized("Russian")
54
+ expect(Languages.from_code(:es)).to match_normalized("Spanish")
55
+ expect(Languages.from_code(:ru)).to match_normalized("Russian")
56
56
  TwitterCldr.locale = :es
57
- Languages.from_code(:es).should match_normalized("español")
57
+ expect(Languages.from_code(:es)).to match_normalized("español")
58
58
  end
59
59
  end
60
60
 
61
61
  describe "#all_for" do
62
62
  it "should return a hash of all languages for the given language code" do
63
63
  langs = Languages.all_for(:es)
64
- langs.should be_a(Hash)
65
- langs[:ru].should match_normalized("ruso")
64
+ expect(langs).to be_a(Hash)
65
+ expect(langs[:ru]).to match_normalized("ruso")
66
66
  end
67
67
 
68
68
  it "should return an empty hash for an invalid language" do
69
69
  langs = Languages.all_for(:blarg)
70
- langs.should == {}
70
+ expect(langs).to eq({})
71
71
  end
72
72
  end
73
73
 
74
74
  describe "#all" do
75
75
  it "should use the default language to get the language hash" do
76
76
  langs = Languages.all
77
- langs.should be_a(Hash)
78
- langs[:ru].should match_normalized("Russian")
79
- langs[:de].should match_normalized("German")
77
+ expect(langs).to be_a(Hash)
78
+ expect(langs[:ru]).to match_normalized("Russian")
79
+ expect(langs[:de]).to match_normalized("German")
80
80
 
81
81
  TwitterCldr.locale = :es
82
82
  langs = Languages.all
83
- langs.should be_a(Hash)
84
- langs[:ru].should match_normalized("ruso")
85
- langs[:de].should match_normalized("alemán")
83
+ expect(langs).to be_a(Hash)
84
+ expect(langs[:ru]).to match_normalized("ruso")
85
+ expect(langs[:de]).to match_normalized("alemán")
86
86
  end
87
87
  end
88
88
 
89
89
  describe "#is_rtl?" do
90
90
  it "should return true for certain locales" do
91
91
  [:ar, :he, :ur, :fa].each do |locale|
92
- Languages.is_rtl?(locale).should be_true
92
+ expect(Languages.is_rtl?(locale)).to be_true
93
93
  end
94
94
  end
95
95
 
96
96
  it "should return false for certain locales" do
97
97
  [:en, :es, :hu, :ja].each do |locale|
98
- Languages.is_rtl?(locale).should be_false
98
+ expect(Languages.is_rtl?(locale)).to be_false
99
99
  end
100
100
  end
101
101
 
102
102
  it "should not raise errors for any locale" do
103
103
  TwitterCldr.supported_locales.each do |locale|
104
- lambda { Languages.is_rtl?(locale) }.should_not raise_error
104
+ expect { Languages.is_rtl?(locale) }.not_to raise_error
105
105
  end
106
106
  end
107
107
  end
@@ -10,12 +10,12 @@ include TwitterCldr::Shared
10
10
  describe NumberingSystem do
11
11
  describe "#for_name" do
12
12
  it "should return the correct numbering system for the given name" do
13
- NumberingSystem.for_name("latn").digits.should == %w(0 1 2 3 4 5 6 7 8 9)
14
- NumberingSystem.for_name("arab").digits.should == %w(٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩)
13
+ expect(NumberingSystem.for_name("latn").digits).to eq(%w(0 1 2 3 4 5 6 7 8 9))
14
+ expect(NumberingSystem.for_name("arab").digits).to eq(%w(٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩))
15
15
  end
16
16
 
17
17
  it "should raise an error if the system is not numeric" do
18
- lambda { NumberingSystem.for_name("roman") }.should raise_error(UnsupportedNumberingSystemError)
18
+ expect { NumberingSystem.for_name("roman") }.to raise_error(UnsupportedNumberingSystemError)
19
19
  end
20
20
  end
21
21
 
@@ -24,8 +24,8 @@ describe NumberingSystem do
24
24
  let(:system) { NumberingSystem.for_name("arab") }
25
25
 
26
26
  it "replaces ascii numeral characters with arabic ones" do
27
- system.transliterate(123).should match_normalized("١٢٣")
28
- system.transliterate(947).should match_normalized("٩٤٧")
27
+ expect(system.transliterate(123)).to match_normalized("١٢٣")
28
+ expect(system.transliterate(947)).to match_normalized("٩٤٧")
29
29
  end
30
30
  end
31
31
 
@@ -33,8 +33,8 @@ describe NumberingSystem do
33
33
  let(:system) { NumberingSystem.for_name("hanidec") }
34
34
 
35
35
  it "replaces ascii numeral characters with Han ones" do
36
- system.transliterate(123).should match_normalized("一二三")
37
- system.transliterate(947).should match_normalized("九四七")
36
+ expect(system.transliterate(123)).to match_normalized("一二三")
37
+ expect(system.transliterate(947)).to match_normalized("九四七")
38
38
  end
39
39
  end
40
40
  end