twitter_cldr 4.3.1 → 4.4.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.
- checksums.yaml +4 -4
- data/Gemfile +3 -7
- data/README.md +5 -5
- data/lib/twitter_cldr/collation/sort_key_builder.rb +5 -5
- data/lib/twitter_cldr/core_ext.rb +2 -8
- data/lib/twitter_cldr/parsers/parser.rb +4 -4
- data/lib/twitter_cldr/utils/range_set.rb +3 -1
- data/lib/twitter_cldr/utils/yaml.rb +17 -17
- data/lib/twitter_cldr/version.rb +1 -1
- data/spec/collation/collator_spec.rb +55 -34
- data/spec/collation/sort_key_builder_spec.rb +3 -3
- data/spec/collation/trie_builder_spec.rb +7 -5
- data/spec/collation/trie_loader_spec.rb +5 -1
- data/spec/collation/trie_with_fallback_spec.rb +4 -4
- data/spec/core_ext_spec.rb +1 -7
- data/spec/data_readers/date_time_data_reader_spec.rb +1 -1
- data/spec/data_readers/number_data_reader_spec.rb +1 -1
- data/spec/formatters/calendars/datetime_formatter_spec.rb +5 -5
- data/spec/formatters/plurals/plural_formatter_spec.rb +3 -3
- data/spec/formatters/plurals/rules_spec.rb +2 -2
- data/spec/localized/localized_array_spec.rb +6 -2
- data/spec/localized/localized_date_spec.rb +1 -1
- data/spec/localized/localized_datetime_spec.rb +2 -4
- data/spec/localized/localized_object_spec.rb +3 -3
- data/spec/localized/localized_string_spec.rb +6 -4
- data/spec/localized/localized_symbol_spec.rb +2 -2
- data/spec/normalization_spec.rb +5 -5
- data/spec/parsers/number_parser_spec.rb +12 -12
- data/spec/parsers/parser_spec.rb +1 -1
- data/spec/resources/loader_spec.rb +31 -31
- data/spec/shared/calendar_spec.rb +5 -5
- data/spec/shared/code_point_spec.rb +5 -5
- data/spec/shared/hyphenator_spec.rb +2 -2
- data/spec/shared/language_codes_spec.rb +7 -7
- data/spec/shared/languages_spec.rb +2 -2
- data/spec/shared/locale_spec.rb +10 -10
- data/spec/shared/numbers_spec.rb +5 -5
- data/spec/shared/phone_codes_spec.rb +4 -2
- data/spec/shared/postal_code_generator_spec.rb +1 -1
- data/spec/shared/properties_database_spec.rb +6 -6
- data/spec/shared/territories_containment_spec.rb +8 -8
- data/spec/shared/territories_spec.rb +10 -6
- data/spec/shared/territory_spec.rb +4 -5
- data/spec/spec_helper.rb +1 -2
- data/spec/twitter_cldr_spec.rb +20 -20
- data/spec/utils/range_set_spec.rb +7 -7
- data/spec/utils/regexp_ast_spec.rb +4 -4
- data/spec/utils/regexp_sampler_spec.rb +23 -23
- metadata +2 -2
@@ -22,7 +22,7 @@ describe Calendar do
|
|
22
22
|
|
23
23
|
describe '#initialize' do
|
24
24
|
it 'returns calendar for default locale and type' do
|
25
|
-
|
25
|
+
allow(TwitterCldr).to receive(:locale).and_return(:fr)
|
26
26
|
cal = Calendar.new
|
27
27
|
|
28
28
|
expect(cal.locale).to eq(:fr)
|
@@ -68,12 +68,12 @@ describe Calendar do
|
|
68
68
|
|
69
69
|
context 'when some data is missing' do
|
70
70
|
it 'returns nil if some names format is missing' do
|
71
|
-
|
71
|
+
allow(TwitterCldr).to receive(:get_locale_resource).and_return(de: { calendars: { gregorian: { months: { :'stand-alone' => {} } } } })
|
72
72
|
expect(calendar.months(:wide)).to eq(nil)
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'returns nil if calendars data is missing' do
|
76
|
-
|
76
|
+
allow(TwitterCldr).to receive(:get_locale_resource).and_return(de: {})
|
77
77
|
expect(calendar.months(:wide)).to eq(nil)
|
78
78
|
end
|
79
79
|
end
|
@@ -128,12 +128,12 @@ describe Calendar do
|
|
128
128
|
|
129
129
|
context 'when some data is missing' do
|
130
130
|
it 'returns nil if some names format is missing' do
|
131
|
-
|
131
|
+
allow(TwitterCldr).to receive(:get_locale_resource).and_return(de: { calendars: { gregorian: { days: { :'stand-alone' => {} } } } })
|
132
132
|
expect(calendar.weekdays(:wide)).to eq(nil)
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'returns nil if calendars data is missing' do
|
136
|
-
|
136
|
+
allow(TwitterCldr).to receive(:get_locale_resource).and_return(de: {})
|
137
137
|
expect(calendar.weekdays(:wide)).to eq(nil)
|
138
138
|
end
|
139
139
|
end
|
@@ -62,7 +62,7 @@ describe CodePoint do
|
|
62
62
|
it 'identifies all properties belonging to the code point' do
|
63
63
|
code_point = CodePoint.get(65)
|
64
64
|
properties = code_point.properties
|
65
|
-
expect(properties.alphabetic).to
|
65
|
+
expect(properties.alphabetic).to eq(true)
|
66
66
|
expect(properties.script).to eq(Set.new(%w(Latin)))
|
67
67
|
expect(properties.general_category).to eq(Set.new(%w(L Lu)))
|
68
68
|
end
|
@@ -80,8 +80,8 @@ describe CodePoint do
|
|
80
80
|
database = Object.new
|
81
81
|
property_name = 'foo'
|
82
82
|
property_value = 'bar'
|
83
|
-
|
84
|
-
|
83
|
+
allow(CodePoint).to receive(:properties).and_return(database)
|
84
|
+
expect(database).to receive(:code_points_for_property).with(property_name, property_value)
|
85
85
|
CodePoint.code_points_for_property(property_name, property_value)
|
86
86
|
end
|
87
87
|
end
|
@@ -90,8 +90,8 @@ describe CodePoint do
|
|
90
90
|
it 'delegates to the properties database' do
|
91
91
|
database = Object.new
|
92
92
|
code_point = 65
|
93
|
-
|
94
|
-
|
93
|
+
allow(CodePoint).to receive(:properties).and_return(database)
|
94
|
+
expect(database).to receive(:properties_for_code_point).with(code_point)
|
95
95
|
CodePoint.properties_for_code_point(code_point)
|
96
96
|
end
|
97
97
|
end
|
@@ -35,11 +35,11 @@ describe Hyphenator do
|
|
35
35
|
|
36
36
|
describe '.supported_locale?' do
|
37
37
|
it 'returns true if the locale is supported' do
|
38
|
-
expect(described_class.supported_locale?(:en)).to
|
38
|
+
expect(described_class.supported_locale?(:en)).to eq(true)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns false if the locale isn't supported" do
|
42
|
-
expect(described_class.supported_locale?(:ko)).to
|
42
|
+
expect(described_class.supported_locale?(:ko)).to eq(false)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -26,25 +26,25 @@ describe LanguageCodes do
|
|
26
26
|
|
27
27
|
describe '#valid_standard?' do
|
28
28
|
it 'returns true if the standard is valid' do
|
29
|
-
expect(LanguageCodes.valid_standard?(:iso_639_2)).to
|
29
|
+
expect(LanguageCodes.valid_standard?(:iso_639_2)).to eq(true)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'returns false if the standard is invalid' do
|
33
|
-
expect(LanguageCodes.valid_standard?(:iso_639)).to
|
33
|
+
expect(LanguageCodes.valid_standard?(:iso_639)).to eq(false)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'accepts a string' do
|
37
|
-
expect(LanguageCodes.valid_standard?('iso_639_2')).to
|
37
|
+
expect(LanguageCodes.valid_standard?('iso_639_2')).to eq(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
|
-
expect(LanguageCodes.valid_code?(:spa, :iso_639_2)).to
|
43
|
+
expect(LanguageCodes.valid_code?(:spa, :iso_639_2)).to eq(true)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns false if the code is not present in the given standard' do
|
47
|
-
expect(LanguageCodes.valid_code?(:foo, :iso_639_2)).to
|
47
|
+
expect(LanguageCodes.valid_code?(:foo, :iso_639_2)).to eq(false)
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'raises exception if the standard is invalid' do
|
@@ -52,7 +52,7 @@ describe LanguageCodes do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'accepts strings' do
|
55
|
-
expect(LanguageCodes.valid_code?('spa', 'iso_639_2')).to
|
55
|
+
expect(LanguageCodes.valid_code?('spa', 'iso_639_2')).to eq(true)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -158,4 +158,4 @@ describe LanguageCodes do
|
|
158
158
|
expect(LanguageCodes.standards_for_language('FooBar')).to eq([])
|
159
159
|
end
|
160
160
|
end
|
161
|
-
end
|
161
|
+
end
|
@@ -89,13 +89,13 @@ describe Languages do
|
|
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
|
-
expect(Languages.is_rtl?(locale)).to
|
92
|
+
expect(Languages.is_rtl?(locale)).to eq(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
|
-
expect(Languages.is_rtl?(locale)).to
|
98
|
+
expect(Languages.is_rtl?(locale)).to eq(false)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
data/spec/shared/locale_spec.rb
CHANGED
@@ -121,27 +121,27 @@ describe Locale do
|
|
121
121
|
|
122
122
|
describe '.valid?' do
|
123
123
|
it 'returns true if all subtags are valid' do
|
124
|
-
expect(Locale.valid?('en')).to
|
125
|
-
expect(Locale.valid?('en-latn')).to
|
126
|
-
expect(Locale.valid?('en-latn-us')).to
|
127
|
-
expect(Locale.valid?('en-latn-us-fonipa')).to
|
124
|
+
expect(Locale.valid?('en')).to eq(true)
|
125
|
+
expect(Locale.valid?('en-latn')).to eq(true)
|
126
|
+
expect(Locale.valid?('en-latn-us')).to eq(true)
|
127
|
+
expect(Locale.valid?('en-latn-us-fonipa')).to eq(true)
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'returns false if any subtag is invalid' do
|
131
|
-
expect(Locale.valid?('xz')).to
|
132
|
-
expect(Locale.valid?('en-fooo')).to
|
133
|
-
expect(Locale.valid?('en-latn-XZ')).to
|
134
|
-
expect(Locale.valid?('en-latn-us-foooo')).to
|
131
|
+
expect(Locale.valid?('xz')).to eq(false)
|
132
|
+
expect(Locale.valid?('en-fooo')).to eq(false)
|
133
|
+
expect(Locale.valid?('en-latn-XZ')).to eq(false)
|
134
|
+
expect(Locale.valid?('en-latn-us-foooo')).to eq(false)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
describe '.grandfathered?' do
|
139
139
|
it 'returns true if the given locale is considered "grandfathered"' do
|
140
|
-
expect(Locale.grandfathered?('i-navajo')).to
|
140
|
+
expect(Locale.grandfathered?('i-navajo')).to eq(true)
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'returns false if the given locale is not considered "grandfathered"' do
|
144
|
-
expect(Locale.grandfathered?('en-latn-us')).to
|
144
|
+
expect(Locale.grandfathered?('en-latn-us')).to eq(false)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
data/spec/shared/numbers_spec.rb
CHANGED
@@ -12,23 +12,23 @@ describe Numbers do
|
|
12
12
|
let(:symbols) { { nan: 'NaN', minus_sign: '-' } }
|
13
13
|
|
14
14
|
it 'returns numerical symbols for default locale' do
|
15
|
-
|
16
|
-
|
15
|
+
allow(TwitterCldr).to receive(:locale).and_return(:jp)
|
16
|
+
allow(TwitterCldr).to receive(:get_locale_resource).with(:jp, :numbers).and_return(jp: { numbers: { symbols: symbols } })
|
17
17
|
expect(TwitterCldr::Shared::Numbers.symbols).to eq(symbols)
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'returns numerical symbols for default locale' do
|
21
|
-
|
21
|
+
allow(TwitterCldr).to receive(:get_locale_resource).with(:np, :numbers).and_return(np: { numbers: { symbols: symbols } })
|
22
22
|
expect(TwitterCldr::Shared::Numbers.symbols(:np)).to eq(symbols)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'converts locale' do
|
26
|
-
|
26
|
+
allow(TwitterCldr).to receive(:get_locale_resource).with(:'zh-Hant', :numbers).and_return(:'zh-Hant' => { numbers: { symbols: symbols } })
|
27
27
|
expect(TwitterCldr::Shared::Numbers.symbols('zh-tw')).to eq(symbols)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'returns nil if the resource is missing' do
|
31
|
-
|
31
|
+
allow(TwitterCldr).to receive(:get_locale_resource).with(:nop, :numbers).and_return(nil)
|
32
32
|
expect(TwitterCldr::Shared::Numbers.symbols(:nop)).to be_nil
|
33
33
|
end
|
34
34
|
end
|
@@ -28,7 +28,9 @@ describe PhoneCodes do
|
|
28
28
|
let(:code) { '123' }
|
29
29
|
let(:territory) { :br }
|
30
30
|
|
31
|
-
before(:each)
|
31
|
+
before(:each) do
|
32
|
+
expect(PhoneCodes).to receive(:resource).and_return({ territory => code })
|
33
|
+
end
|
32
34
|
|
33
35
|
it 'returns phone code for a given territory' do
|
34
36
|
expect(PhoneCodes.code_for_territory(territory)).to eq(code)
|
@@ -46,4 +48,4 @@ describe PhoneCodes do
|
|
46
48
|
expect(PhoneCodes.code_for_territory(territory.to_s.upcase)).to eq(code)
|
47
49
|
end
|
48
50
|
end
|
49
|
-
end
|
51
|
+
end
|
@@ -68,7 +68,7 @@ describe PostalCodeGenerator do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should attempt to generate more samples if the set doesn't contain enough (but shouldn't infinite loop)" do
|
71
|
-
|
71
|
+
expect(limited_generator).to receive(:generate).at_least(10).times.and_call_original
|
72
72
|
expect(limited_generator.sample(10).size).to be < 10
|
73
73
|
end
|
74
74
|
end
|
@@ -69,19 +69,19 @@ describe PropertiesDatabase do
|
|
69
69
|
|
70
70
|
describe '#include?' do
|
71
71
|
it 'returns true if the database contains the property name' do
|
72
|
-
expect(database.include?('Age')).to
|
72
|
+
expect(database.include?('Age')).to eq(true)
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'returns true if the database contains the property name/value pair' do
|
76
|
-
expect(database.include?('Age', '1.1')).to
|
76
|
+
expect(database.include?('Age', '1.1')).to eq(true)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "returns false if the database doesn't contain the property name" do
|
80
|
-
expect(database.include?('foo')).to
|
80
|
+
expect(database.include?('foo')).to eq(false)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "returns false if the database doesn't contain the property name/value pair" do
|
84
|
-
expect(database.include?('Age', 'foo')).to
|
84
|
+
expect(database.include?('Age', 'foo')).to eq(false)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -148,8 +148,8 @@ describe PropertiesDatabase do
|
|
148
148
|
|
149
149
|
it 'delegates normalization to a normalizer' do
|
150
150
|
normalizer = Object.new
|
151
|
-
|
152
|
-
|
151
|
+
allow(database).to receive(:normalizer).and_return(normalizer)
|
152
|
+
expect(normalizer).to receive(:normalize).with(property_name, property_value)
|
153
153
|
database.normalize(property_name, property_value)
|
154
154
|
end
|
155
155
|
end
|
@@ -46,32 +46,32 @@ describe TerritoriesContainment do
|
|
46
46
|
|
47
47
|
describe '.contains?' do
|
48
48
|
it 'returns true if the first territory (immediately) contains the second one' do
|
49
|
-
expect(TerritoriesContainment.contains?('151', 'RU')).to
|
49
|
+
expect(TerritoriesContainment.contains?('151', 'RU')).to eq(true)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'returns true if the first territory (non-immediately) contains the second one' do
|
53
|
-
expect(TerritoriesContainment.contains?('419', 'BZ')).to
|
53
|
+
expect(TerritoriesContainment.contains?('419', 'BZ')).to eq(true)
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'returns true if a territory is part of multiple parent territories' do
|
57
|
-
expect(TerritoriesContainment.contains?('019', '013')).to
|
58
|
-
expect(TerritoriesContainment.contains?('419', '013')).to
|
57
|
+
expect(TerritoriesContainment.contains?('019', '013')).to eq(true)
|
58
|
+
expect(TerritoriesContainment.contains?('419', '013')).to eq(true)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'returns true if the first territory is a top-level territory' do
|
62
|
-
expect(TerritoriesContainment.contains?('001', '145')).to
|
62
|
+
expect(TerritoriesContainment.contains?('001', '145')).to eq(true)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'returns false if the first territory does not contain the second one' do
|
66
|
-
expect(TerritoriesContainment.contains?('419', 'RU')).to
|
66
|
+
expect(TerritoriesContainment.contains?('419', 'RU')).to eq(false)
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'returns false if the second territory is a top-level territory' do
|
70
|
-
expect(TerritoriesContainment.contains?('419', '001')).to
|
70
|
+
expect(TerritoriesContainment.contains?('419', '001')).to eq(false)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'returns false if both territories are identical' do
|
74
|
-
expect(TerritoriesContainment.contains?('RU', 'RU')).to
|
74
|
+
expect(TerritoriesContainment.contains?('RU', 'RU')).to eq(false)
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'raises an exception is the first territory is invalid' do
|
@@ -117,12 +117,16 @@ describe Territories do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
describe "#deep_normalize_territory_code_keys" do
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
120
|
+
it 'normalizes correctly' do
|
121
|
+
normalized = Territories.deep_normalize_territory_code_keys({
|
122
|
+
"is" => [
|
123
|
+
{ "US" => "United States", 5 => "Suður-Ameríka" },
|
124
|
+
{ "009" => "Eyjaálfa" }
|
125
|
+
]
|
126
|
+
})
|
126
127
|
|
128
|
+
expect(normalized).to eq({ is: [{ us: "United States" }, {}] })
|
129
|
+
end
|
130
|
+
end
|
127
131
|
end
|
128
132
|
|
@@ -15,7 +15,7 @@ describe Territory do
|
|
15
15
|
let(:parents) { %w[013 territory parents] }
|
16
16
|
|
17
17
|
it 'delegates to TerritoriesContainment.parents' do
|
18
|
-
|
18
|
+
expect(TerritoriesContainment).to receive(:parents).with(code).and_return(parents)
|
19
19
|
expect(territory.parents).to eq(parents)
|
20
20
|
end
|
21
21
|
end
|
@@ -24,18 +24,17 @@ describe Territory do
|
|
24
24
|
let(:children) { %w[013 territory children] }
|
25
25
|
|
26
26
|
it 'delegates to TerritoriesContainment.children' do
|
27
|
-
|
27
|
+
expect(TerritoriesContainment).to receive(:children).with(code).and_return(children)
|
28
28
|
expect(territory.children).to eq(children)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#contains?' do
|
33
33
|
let(:other_code) { 'RU' }
|
34
|
-
let(:result) { 'containment result' }
|
35
34
|
|
36
35
|
it 'delegates to TerritoriesContainment.contains?' do
|
37
|
-
|
38
|
-
|
36
|
+
expect(TerritoriesContainment).to receive(:contains?).with(code, other_code)
|
37
|
+
territory.contains?(other_code)
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
|
6
6
|
require 'rspec'
|
7
|
-
require 'rspec/autorun' # somehow makes rcov work with rspec
|
8
7
|
require 'twitter_cldr'
|
9
8
|
require 'pry-nav'
|
10
9
|
require 'coveralls'
|
@@ -46,7 +45,7 @@ module I18n
|
|
46
45
|
end
|
47
46
|
|
48
47
|
RSpec.configure do |config|
|
49
|
-
config.mock_with :rr
|
48
|
+
# config.mock_with :rr
|
50
49
|
|
51
50
|
config.filter_run(focus: true)
|
52
51
|
config.run_all_when_everything_filtered = true
|
data/spec/twitter_cldr_spec.rb
CHANGED
@@ -8,29 +8,29 @@ require 'spec_helper'
|
|
8
8
|
describe TwitterCldr do
|
9
9
|
describe "#supported_locale?" do
|
10
10
|
it "should return true if the locale is supported" do
|
11
|
-
expect(TwitterCldr.supported_locale?(:es)).to
|
12
|
-
expect(TwitterCldr.supported_locale?("es")).to
|
11
|
+
expect(TwitterCldr.supported_locale?(:es)).to eq(true)
|
12
|
+
expect(TwitterCldr.supported_locale?("es")).to eq(true)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return false if the locale isn't supported" do
|
16
|
-
expect(TwitterCldr.supported_locale?(:bogus)).to
|
17
|
-
expect(TwitterCldr.supported_locale?("bogus")).to
|
16
|
+
expect(TwitterCldr.supported_locale?(:bogus)).to eq(false)
|
17
|
+
expect(TwitterCldr.supported_locale?("bogus")).to eq(false)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return true if the given locale code is twitter-specific" do
|
21
|
-
expect(TwitterCldr.supported_locale?(:'zh-cn')).to
|
22
|
-
expect(TwitterCldr.supported_locale?(:'zh-tw')).to
|
23
|
-
expect(TwitterCldr.supported_locale?(:msa)).to
|
21
|
+
expect(TwitterCldr.supported_locale?(:'zh-cn')).to eq(true)
|
22
|
+
expect(TwitterCldr.supported_locale?(:'zh-tw')).to eq(true)
|
23
|
+
expect(TwitterCldr.supported_locale?(:msa)).to eq(true)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should work with lowercase region codes" do
|
27
|
-
expect(TwitterCldr.supported_locale?('en-gb')).to
|
28
|
-
expect(TwitterCldr.supported_locale?('zh-hant')).to
|
27
|
+
expect(TwitterCldr.supported_locale?('en-gb')).to eq(true)
|
28
|
+
expect(TwitterCldr.supported_locale?('zh-hant')).to eq(true)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should work with upper case region codes" do
|
32
|
-
expect(TwitterCldr.supported_locale?('en-GB')).to
|
33
|
-
expect(TwitterCldr.supported_locale?('zh-Hant')).to
|
32
|
+
expect(TwitterCldr.supported_locale?('en-GB')).to eq(true)
|
33
|
+
expect(TwitterCldr.supported_locale?('zh-Hant')).to eq(true)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -272,9 +272,9 @@ describe TwitterCldr do
|
|
272
272
|
expect do
|
273
273
|
TwitterCldr.with_locale(:es) do
|
274
274
|
locale_inside_block = TwitterCldr.locale
|
275
|
-
raise "Error!"
|
275
|
+
raise RuntimeError, "Error!"
|
276
276
|
end
|
277
|
-
end.to raise_error
|
277
|
+
end.to raise_error(RuntimeError, "Error!")
|
278
278
|
|
279
279
|
expect(locale_inside_block).to eq(:es)
|
280
280
|
expect(TwitterCldr.locale).to eq(:en)
|
@@ -291,7 +291,7 @@ describe TwitterCldr do
|
|
291
291
|
it "doesn't mess up if the given locale isn't supported" do
|
292
292
|
TwitterCldr.locale = :pt
|
293
293
|
expect(TwitterCldr.locale).to eq(:pt)
|
294
|
-
expect { TwitterCldr.with_locale(:xx) {} }.to raise_error
|
294
|
+
expect { TwitterCldr.with_locale(:xx) {} }.to raise_error(RuntimeError, 'Unsupported locale')
|
295
295
|
expect(TwitterCldr.locale).to eq(:pt)
|
296
296
|
end
|
297
297
|
|
@@ -302,9 +302,9 @@ describe TwitterCldr do
|
|
302
302
|
expect do
|
303
303
|
TwitterCldr.with_locale(:es) do
|
304
304
|
locale_inside_block = TwitterCldr.locale
|
305
|
-
raise "Error!"
|
305
|
+
raise RuntimeError, "Error!"
|
306
306
|
end
|
307
|
-
end.to raise_error
|
307
|
+
end.to raise_error(RuntimeError, "Error!")
|
308
308
|
|
309
309
|
expect(locale_inside_block).to eq(:es)
|
310
310
|
expect(TwitterCldr.locale).to eq(:en)
|
@@ -324,8 +324,8 @@ describe TwitterCldr do
|
|
324
324
|
|
325
325
|
describe '#get_resource' do
|
326
326
|
it 'delegates to resources' do
|
327
|
-
|
328
|
-
|
327
|
+
allow(resources).to receive(:get_resource).with(:shared, :currencies).and_return('result')
|
328
|
+
allow(TwitterCldr).to receive(:resources).and_return(resources)
|
329
329
|
|
330
330
|
expect(TwitterCldr.get_resource(:shared, :currencies)).to eq('result')
|
331
331
|
end
|
@@ -333,8 +333,8 @@ describe TwitterCldr do
|
|
333
333
|
|
334
334
|
describe '#get_locale_resource' do
|
335
335
|
it 'delegates to resources' do
|
336
|
-
|
337
|
-
|
336
|
+
allow(resources).to receive(:get_locale_resource).with(:de, :numbers).and_return('result')
|
337
|
+
allow(TwitterCldr).to receive(:resources).and_return(resources)
|
338
338
|
|
339
339
|
expect(TwitterCldr.get_locale_resource(:de, :numbers)).to eq('result')
|
340
340
|
end
|