twitter_cldr 4.3.1 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -7
  3. data/README.md +5 -5
  4. data/lib/twitter_cldr/collation/sort_key_builder.rb +5 -5
  5. data/lib/twitter_cldr/core_ext.rb +2 -8
  6. data/lib/twitter_cldr/parsers/parser.rb +4 -4
  7. data/lib/twitter_cldr/utils/range_set.rb +3 -1
  8. data/lib/twitter_cldr/utils/yaml.rb +17 -17
  9. data/lib/twitter_cldr/version.rb +1 -1
  10. data/spec/collation/collator_spec.rb +55 -34
  11. data/spec/collation/sort_key_builder_spec.rb +3 -3
  12. data/spec/collation/trie_builder_spec.rb +7 -5
  13. data/spec/collation/trie_loader_spec.rb +5 -1
  14. data/spec/collation/trie_with_fallback_spec.rb +4 -4
  15. data/spec/core_ext_spec.rb +1 -7
  16. data/spec/data_readers/date_time_data_reader_spec.rb +1 -1
  17. data/spec/data_readers/number_data_reader_spec.rb +1 -1
  18. data/spec/formatters/calendars/datetime_formatter_spec.rb +5 -5
  19. data/spec/formatters/plurals/plural_formatter_spec.rb +3 -3
  20. data/spec/formatters/plurals/rules_spec.rb +2 -2
  21. data/spec/localized/localized_array_spec.rb +6 -2
  22. data/spec/localized/localized_date_spec.rb +1 -1
  23. data/spec/localized/localized_datetime_spec.rb +2 -4
  24. data/spec/localized/localized_object_spec.rb +3 -3
  25. data/spec/localized/localized_string_spec.rb +6 -4
  26. data/spec/localized/localized_symbol_spec.rb +2 -2
  27. data/spec/normalization_spec.rb +5 -5
  28. data/spec/parsers/number_parser_spec.rb +12 -12
  29. data/spec/parsers/parser_spec.rb +1 -1
  30. data/spec/resources/loader_spec.rb +31 -31
  31. data/spec/shared/calendar_spec.rb +5 -5
  32. data/spec/shared/code_point_spec.rb +5 -5
  33. data/spec/shared/hyphenator_spec.rb +2 -2
  34. data/spec/shared/language_codes_spec.rb +7 -7
  35. data/spec/shared/languages_spec.rb +2 -2
  36. data/spec/shared/locale_spec.rb +10 -10
  37. data/spec/shared/numbers_spec.rb +5 -5
  38. data/spec/shared/phone_codes_spec.rb +4 -2
  39. data/spec/shared/postal_code_generator_spec.rb +1 -1
  40. data/spec/shared/properties_database_spec.rb +6 -6
  41. data/spec/shared/territories_containment_spec.rb +8 -8
  42. data/spec/shared/territories_spec.rb +10 -6
  43. data/spec/shared/territory_spec.rb +4 -5
  44. data/spec/spec_helper.rb +1 -2
  45. data/spec/twitter_cldr_spec.rb +20 -20
  46. data/spec/utils/range_set_spec.rb +7 -7
  47. data/spec/utils/regexp_ast_spec.rb +4 -4
  48. data/spec/utils/regexp_sampler_spec.rb +23 -23
  49. 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
- stub(TwitterCldr).locale { :fr }
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
- stub(TwitterCldr).get_locale_resource { { de: { calendars: { gregorian: { months: { :'stand-alone' => {} } } } } } }
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
- stub(TwitterCldr).get_locale_resource { { de: {} } }
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
- stub(TwitterCldr).get_locale_resource { { de: { calendars: { gregorian: { days: { :'stand-alone' => {} } } } } } }
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
- stub(TwitterCldr).get_locale_resource { { de: {} } }
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 be_true
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
- stub(CodePoint).properties { database }
84
- mock(database).code_points_for_property(property_name, property_value)
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
- stub(CodePoint).properties { database }
94
- mock(database).properties_for_code_point(code_point)
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 be_true
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 be_false
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 be_true
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 be_false
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 be_true
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 be_true
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 be_false
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 be_true
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 be_true
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 be_false
98
+ expect(Languages.is_rtl?(locale)).to eq(false)
99
99
  end
100
100
  end
101
101
 
@@ -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 be_true
125
- expect(Locale.valid?('en-latn')).to be_true
126
- expect(Locale.valid?('en-latn-us')).to be_true
127
- expect(Locale.valid?('en-latn-us-fonipa')).to be_true
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 be_false
132
- expect(Locale.valid?('en-fooo')).to be_false
133
- expect(Locale.valid?('en-latn-XZ')).to be_false
134
- expect(Locale.valid?('en-latn-us-foooo')).to be_false
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 be_true
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 be_false
144
+ expect(Locale.grandfathered?('en-latn-us')).to eq(false)
145
145
  end
146
146
  end
147
147
 
@@ -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
- stub(TwitterCldr).locale { :jp }
16
- stub(TwitterCldr).get_locale_resource(:jp, :numbers) { { jp: { numbers: { symbols: symbols } } } }
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
- stub(TwitterCldr).get_locale_resource(:np, :numbers) { { np: { numbers: { symbols: symbols } } } }
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
- stub(TwitterCldr).get_locale_resource(:'zh-Hant', :numbers) { { :'zh-Hant' => { numbers: { symbols: symbols } } } }
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
- stub(TwitterCldr).get_locale_resource(:nop, :numbers) { nil }
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) { mock(PhoneCodes).resource { { territory => code } } }
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
- mock.proxy(limited_generator).generate.at_least(10)
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 be_true
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 be_true
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 be_false
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 be_false
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
- stub(database).normalizer { normalizer }
152
- mock(normalizer).normalize(property_name, property_value)
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 be_true
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 be_true
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 be_true
58
- expect(TerritoriesContainment.contains?('419', '013')).to be_true
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 be_true
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 be_false
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 be_false
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 be_false
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
- Territories.deep_normalize_territory_code_keys(
121
- { "is" => [ { "US" => "United States",
122
- 5 => "Suður-Ameríka" },
123
- { "009" => "Eyjaálfa" } ] }
124
- ).should == { is: [ { us: "United States" }, { } ] }
125
- end
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
- mock(TerritoriesContainment).parents(code) { parents }
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
- mock(TerritoriesContainment).children(code) { children }
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
- mock(TerritoriesContainment).contains?(code, other_code) { result }
38
- expect(territory.contains?(other_code)).to be_true
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
@@ -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 be_true
12
- expect(TwitterCldr.supported_locale?("es")).to be_true
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 be_false
17
- expect(TwitterCldr.supported_locale?("bogus")).to be_false
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 be_true
22
- expect(TwitterCldr.supported_locale?(:'zh-tw')).to be_true
23
- expect(TwitterCldr.supported_locale?(:msa)).to be_true
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 be_true
28
- expect(TwitterCldr.supported_locale?('zh-hant')).to be_true
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 be_true
33
- expect(TwitterCldr.supported_locale?('zh-Hant')).to be_true
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
- stub(resources).get_resource(:shared, :currencies) { 'result' }
328
- stub(TwitterCldr).resources { resources }
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
- stub(resources).get_locale_resource(:de, :numbers) { 'result' }
337
- stub(TwitterCldr).resources { resources }
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