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,11 +10,11 @@ include TwitterCldr::Formatters
10
10
  describe ListFormatter do
11
11
  describe '#initialize' do
12
12
  it 'fetches locale from options hash' do
13
- ListFormatter.new(:pt).locale.should == :pt
13
+ expect(ListFormatter.new(:pt).locale).to eq(:pt)
14
14
  end
15
15
 
16
16
  it "uses default locale if it's not passed in options hash" do
17
- ListFormatter.new.locale.should == TwitterCldr.locale
17
+ expect(ListFormatter.new.locale).to eq(TwitterCldr.locale)
18
18
  end
19
19
  end
20
20
 
@@ -27,9 +27,9 @@ describe ListFormatter do
27
27
  end
28
28
 
29
29
  it "formats English lists correctly using various types" do
30
- @formatter.format(list).should == "larry, curly, and moe"
31
- @formatter.format(list, :unit).should == "larry, curly, moe"
32
- @formatter.format(list, :"unit-narrow").should == "larry curly moe"
30
+ expect(@formatter.format(list)).to eq("larry, curly, and moe")
31
+ expect(@formatter.format(list, :unit)).to eq("larry, curly, moe")
32
+ expect(@formatter.format(list, :"unit-narrow")).to eq("larry curly moe")
33
33
  end
34
34
  end
35
35
 
@@ -39,9 +39,9 @@ describe ListFormatter do
39
39
  end
40
40
 
41
41
  it "formats Spanish lists correctly using various types" do
42
- @formatter.format(list).should == "larry, curly y moe"
43
- @formatter.format(list, :unit).should == "larry, curly y moe"
44
- @formatter.format(list, :"unit-narrow").should == "larry curly moe"
42
+ expect(@formatter.format(list)).to eq("larry, curly y moe")
43
+ expect(@formatter.format(list, :unit)).to eq("larry, curly y moe")
44
+ expect(@formatter.format(list, :"unit-narrow")).to eq("larry curly moe")
45
45
  end
46
46
  end
47
47
  end
@@ -12,26 +12,26 @@ describe AbbreviatedNumberFormatter do
12
12
 
13
13
  describe "#transform_number" do
14
14
  it "chops off the number to the necessary number of sig figs" do
15
- formatter.send(:transform_number, 10 ** 3).should == 1
16
- formatter.send(:transform_number, 10 ** 4).should == 10
17
- formatter.send(:transform_number, 10 ** 5).should == 100
18
- formatter.send(:transform_number, 10 ** 6).should == 1
19
- formatter.send(:transform_number, 10 ** 7).should == 10
20
- formatter.send(:transform_number, 10 ** 8).should == 100
21
- formatter.send(:transform_number, 10 ** 9).should == 1
22
- formatter.send(:transform_number, 10 ** 10).should == 10
23
- formatter.send(:transform_number, 10 ** 11).should == 100
24
- formatter.send(:transform_number, 10 ** 12).should == 1
25
- formatter.send(:transform_number, 10 ** 13).should == 10
26
- formatter.send(:transform_number, 10 ** 14).should == 100
15
+ expect(formatter.send(:transform_number, 10 ** 3)).to eq(1)
16
+ expect(formatter.send(:transform_number, 10 ** 4)).to eq(10)
17
+ expect(formatter.send(:transform_number, 10 ** 5)).to eq(100)
18
+ expect(formatter.send(:transform_number, 10 ** 6)).to eq(1)
19
+ expect(formatter.send(:transform_number, 10 ** 7)).to eq(10)
20
+ expect(formatter.send(:transform_number, 10 ** 8)).to eq(100)
21
+ expect(formatter.send(:transform_number, 10 ** 9)).to eq(1)
22
+ expect(formatter.send(:transform_number, 10 ** 10)).to eq(10)
23
+ expect(formatter.send(:transform_number, 10 ** 11)).to eq(100)
24
+ expect(formatter.send(:transform_number, 10 ** 12)).to eq(1)
25
+ expect(formatter.send(:transform_number, 10 ** 13)).to eq(10)
26
+ expect(formatter.send(:transform_number, 10 ** 14)).to eq(100)
27
27
  end
28
28
 
29
29
  it "returns the original number if greater than 10^15" do
30
- formatter.send(:transform_number, 10 ** 15).should == 10 ** 15
30
+ expect(formatter.send(:transform_number, 10 ** 15)).to eq(10 ** 15)
31
31
  end
32
32
 
33
33
  it "returns the original number if less than 10^3" do
34
- formatter.send(:transform_number, 999).should == 999
34
+ expect(formatter.send(:transform_number, 999)).to eq(999)
35
35
  end
36
36
  end
37
37
  end
@@ -33,7 +33,7 @@ describe LongDecimalFormatter do
33
33
 
34
34
  expected.each do |num, text|
35
35
  pattern = data_reader.pattern(num)
36
- formatter.format(tokenizer.tokenize(pattern), num).should == text
36
+ expect(formatter.format(tokenizer.tokenize(pattern), num)).to eq(text)
37
37
  end
38
38
  end
39
39
 
@@ -43,14 +43,14 @@ describe LongDecimalFormatter do
43
43
  end
44
44
 
45
45
  it "formats the number as if it were a straight decimal if it exceeds 10^15" do
46
- format_number(10**15).should == "1,000,000,000,000,000"
46
+ expect(format_number(10**15)).to eq("1,000,000,000,000,000")
47
47
  end
48
48
 
49
49
  it "formats the number as if it were a straight decimal if it's less than 1000" do
50
- format_number(500).should == "500"
50
+ expect(format_number(500)).to eq("500")
51
51
  end
52
52
 
53
53
  it "respects the :precision option" do
54
- format_number(12345, :precision => 3).should match_normalized("12.345 thousand")
54
+ expect(format_number(12345, :precision => 3)).to match_normalized("12.345 thousand")
55
55
  end
56
56
  end
@@ -33,25 +33,25 @@ describe ShortDecimalFormatter do
33
33
 
34
34
  expected.each do |num, text|
35
35
  pattern = data_reader.pattern(num)
36
- formatter.format(tokenizer.tokenize(pattern), num).should == text
36
+ expect(formatter.format(tokenizer.tokenize(pattern), num)).to eq(text)
37
37
  end
38
38
  end
39
39
 
40
40
  it "formats the number as if it were a straight decimal if it exceeds 10^15" do
41
41
  number = 10**15
42
42
  pattern = data_reader.pattern(number)
43
- formatter.format(tokenizer.tokenize(pattern), number).should == "1,000,000,000,000,000"
43
+ expect(formatter.format(tokenizer.tokenize(pattern), number)).to eq("1,000,000,000,000,000")
44
44
  end
45
45
 
46
46
  it "formats the number as if it were a straight decimal if it's less than 1000" do
47
47
  number = 500
48
48
  pattern = data_reader.pattern(number)
49
- formatter.format(tokenizer.tokenize(pattern), number).should == "500"
49
+ expect(formatter.format(tokenizer.tokenize(pattern), number)).to eq("500")
50
50
  end
51
51
 
52
52
  it "respects the :precision option" do
53
53
  number = 12345
54
54
  pattern = data_reader.pattern(number)
55
- formatter.format(tokenizer.tokenize(pattern), number, :precision => 3).should match_normalized("12.345K")
55
+ expect(formatter.format(tokenizer.tokenize(pattern), number, :precision => 3)).to match_normalized("12.345K")
56
56
  end
57
57
  end
@@ -19,45 +19,45 @@ describe CurrencyFormatter do
19
19
  end
20
20
 
21
21
  it "should use a dollar sign when no other currency symbol is given (and default to a precision of 2)" do
22
- format_currency(12).should == "$12.00"
22
+ expect(format_currency(12)).to eq("$12.00")
23
23
  end
24
24
 
25
25
  it "handles negative numbers" do
26
26
  # yes, the parentheses really are part of the format, don't worry about it
27
- format_currency(-12).should == "($12.00)"
27
+ expect(format_currency(-12)).to eq("($12.00)")
28
28
  end
29
29
 
30
30
  it "should use the specified currency symbol when specified" do
31
31
  # S/. is the symbol for the Peruvian Nuevo Sol, just in case you were curious
32
- format_currency(12, :symbol => "S/.").should == "S/.12.00"
32
+ expect(format_currency(12, :symbol => "S/.")).to eq("S/.12.00")
33
33
  end
34
34
 
35
35
  it "should use the currency code as the symbol if the currency code can't be identified" do
36
- format_currency(12, :currency => "XYZ").should == "XYZ12.00"
36
+ expect(format_currency(12, :currency => "XYZ")).to eq("XYZ12.00")
37
37
  end
38
38
 
39
39
  it "should respect the :use_cldr_symbol option" do
40
- format_currency(12, :currency => "CAD").should == "$12.00"
41
- format_currency(12, :currency => "CAD", :use_cldr_symbol => true).should == "CA$12.00"
40
+ expect(format_currency(12, :currency => "CAD")).to eq("$12.00")
41
+ expect(format_currency(12, :currency => "CAD", :use_cldr_symbol => true)).to eq("CA$12.00")
42
42
  end
43
43
 
44
44
  it "should use the currency symbol for the corresponding currency code" do
45
- format_currency(12, :currency => "THB").should == "฿12.00"
45
+ expect(format_currency(12, :currency => "THB")).to eq("฿12.00")
46
46
  end
47
47
 
48
48
  it "overrides the default precision" do
49
- format_currency(12, :precision => 3).should == "$12.000"
49
+ expect(format_currency(12, :precision => 3)).to eq("$12.000")
50
50
  end
51
51
 
52
52
  it "should use the currency-specific default precision" do
53
- format_currency(12, :currency => "TND").should == "TND12.000"
53
+ expect(format_currency(12, :currency => "TND")).to eq("TND12.000")
54
54
  end
55
55
 
56
56
  it "should use the currency rounding for the currency code" do
57
57
  # The rounding value for CHF changed from 5 to 0 in CLDR 23, so we have to pass
58
58
  # :rounding explicitly to test its effects.
59
- format_currency(12.03, :currency => "CHF", :rounding => 5).should == "CHF12.05"
60
- format_currency(12.02, :currency => "CHF", :rounding => 5).should == "CHF12.00"
59
+ expect(format_currency(12.03, :currency => "CHF", :rounding => 5)).to eq("CHF12.05")
60
+ expect(format_currency(12.02, :currency => "CHF", :rounding => 5)).to eq("CHF12.00")
61
61
  end
62
62
  end
63
63
  end
@@ -18,20 +18,20 @@ describe DecimalFormatter do
18
18
  it "should format positive decimals correctly" do
19
19
  pattern = data_reader.pattern(number)
20
20
  tokens = tokenizer.tokenize(pattern)
21
- formatter.format(tokens, number).should == "12"
21
+ expect(formatter.format(tokens, number)).to eq("12")
22
22
  end
23
23
 
24
24
  it "should format negative decimals correctly" do
25
25
  pattern = data_reader.pattern(negative_number)
26
26
  tokens = tokenizer.tokenize(pattern)
27
- formatter.format(tokens, negative_number).should == "-12"
27
+ expect(formatter.format(tokens, negative_number)).to eq("-12")
28
28
  end
29
29
 
30
30
  it "should respect the :precision option" do
31
31
  { number => "12,000", negative_number => "-12,000" }.each_pair do |num, formatted|
32
32
  pattern = data_reader.pattern(num)
33
33
  tokens = tokenizer.tokenize(pattern)
34
- formatter.format(tokens, num, :precision => 3).should == formatted
34
+ expect(formatter.format(tokens, num, :precision => 3)).to eq(formatted)
35
35
  end
36
36
  end
37
37
  end
@@ -12,17 +12,17 @@ describe Fraction do
12
12
  describe "#apply" do
13
13
  it "test: formats a fraction" do
14
14
  token = Token.new(:value => '###.##', :type => :pattern)
15
- Fraction.new(token).apply('45').should == '.45'
15
+ expect(Fraction.new(token).apply('45')).to eq('.45')
16
16
  end
17
17
 
18
18
  it "test: pads zero digits on the right side" do
19
19
  token = Token.new(:value => '###.0000#', :type => :pattern)
20
- Fraction.new(token).apply('45').should == '.45000'
20
+ expect(Fraction.new(token).apply('45')).to eq('.45000')
21
21
  end
22
22
 
23
23
  it "test: :precision option overrides format precision" do
24
24
  token = Token.new(:value => '###.##', :type => :pattern)
25
- Fraction.new(token).apply('78901', :precision => 5).should == '.78901'
25
+ expect(Fraction.new(token).apply('78901', :precision => 5)).to eq('.78901')
26
26
  end
27
27
  end
28
28
  end
@@ -16,19 +16,19 @@ describe Integer do
16
16
  end
17
17
 
18
18
  it "test: interpolates a number" do
19
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123).should == '123'
19
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123)).to eq('123')
20
20
  end
21
21
 
22
22
  it "test: does not include a fraction for a float" do
23
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123.45).should == '123'
23
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123.45)).to eq('123')
24
24
  end
25
25
 
26
26
  it "test: does not round when given a float" do
27
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123.55).should == '123'
27
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123.55)).to eq('123')
28
28
  end
29
29
 
30
30
  it "test: does not round with :precision => 1" do
31
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123.55, :precision => 1).should == '123'
31
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123.55, :precision => 1)).to eq('123')
32
32
  end
33
33
  end
34
34
 
@@ -38,11 +38,11 @@ describe Integer do
38
38
  end
39
39
 
40
40
  it "test: single group" do
41
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123).should == '1,23'
41
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123)).to eq('1,23')
42
42
  end
43
43
 
44
44
  it "test: multiple groups with a primary group size" do
45
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123456789).should == '1,23,45,67,89'
45
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(123456789)).to eq('1,23,45,67,89')
46
46
  end
47
47
  end
48
48
 
@@ -52,53 +52,53 @@ describe Integer do
52
52
  end
53
53
 
54
54
  it "test: ignores a fraction part given in the format string" do
55
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(1234.567).should == '1,234'
55
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(1234.567)).to eq('1,234')
56
56
  end
57
57
 
58
58
  it "test: cldr example #,##0.## => 1 234" do
59
- TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(1234.567).should == '1,234'
59
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(@token).apply(1234.567)).to eq('1,234')
60
60
  end
61
61
  end
62
62
 
63
63
  context "miscellaneous formats" do
64
64
  it "test: interpolates a number on the right side" do
65
65
  token = Token.new(:value => "0###", :type => :pattern)
66
- TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123).should == '0123'
66
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123)).to eq('0123')
67
67
  end
68
68
 
69
69
  it "test: strips optional digits" do
70
70
  token = Token.new(:value => "######", :type => :pattern)
71
- TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123).should == '123'
71
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123)).to eq('123')
72
72
  end
73
73
 
74
74
  it "test: multiple groups with a primary and secondary group size" do
75
75
  token = Token.new(:value => "#,##,##0", :type => :pattern)
76
- TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123456789).should == '12,34,56,789'
76
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123456789)).to eq('12,34,56,789')
77
77
  end
78
78
 
79
79
  it "test: does not group when no digits left of the grouping position" do
80
80
  token = Token.new(:value => "#,###", :type => :pattern)
81
- TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123).should == '123'
81
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token).apply(123)).to eq('123')
82
82
  end
83
83
 
84
84
  it "test: cldr example #,##0.### => 1 234" do
85
85
  token = Token.new(:value => "#,##0.###", :type => :pattern)
86
- TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567).should == '1 234'
86
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567)).to eq('1 234')
87
87
  end
88
88
 
89
89
  it "test: cldr example ###0.##### => 1234" do
90
90
  token = Token.new(:value => "###0.#####", :type => :pattern)
91
- TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567).should == '1234'
91
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567)).to eq('1234')
92
92
  end
93
93
 
94
94
  it "test: cldr example ###0.0000# => 1234" do
95
95
  token = Token.new(:value => "###0.0000#", :type => :pattern)
96
- TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567).should == '1234'
96
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567)).to eq('1234')
97
97
  end
98
98
 
99
99
  it "test: cldr example 00000.0000 => 01234" do
100
100
  token = Token.new(:value => "00000.0000", :type => :pattern)
101
- TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567).should == '01234'
101
+ expect(TwitterCldr::Formatters::Numbers::Integer.new(token, :group => ' ').apply(1234.567)).to eq('01234')
102
102
  end
103
103
  end
104
104
  end
@@ -25,33 +25,33 @@ describe NumberFormatter do
25
25
 
26
26
  describe "#precision_from" do
27
27
  it "should return the correct precision" do
28
- formatter.send(:precision_from, 12.123).should == 3
28
+ expect(formatter.send(:precision_from, 12.123)).to eq(3)
29
29
  end
30
30
 
31
31
  it "should return zero precision if the number isn't a decimal" do
32
- formatter.send(:precision_from, 12).should == 0
32
+ expect(formatter.send(:precision_from, 12)).to eq(0)
33
33
  end
34
34
  end
35
35
 
36
36
  describe "#round_to" do
37
37
  it "should round a number to the given precision" do
38
- formatter.send(:round_to, 12, 0).should == 12
39
- formatter.send(:round_to, 12.2, 0).should == 12
40
- formatter.send(:round_to, 12.5, 0).should == 13
41
- formatter.send(:round_to, 12.25, 1).should == 12.3
42
- formatter.send(:round_to, 12.25, 2).should == 12.25
43
- formatter.send(:round_to, 12.25, 3).should == 12.25
38
+ expect(formatter.send(:round_to, 12, 0)).to eq(12)
39
+ expect(formatter.send(:round_to, 12.2, 0)).to eq(12)
40
+ expect(formatter.send(:round_to, 12.5, 0)).to eq(13)
41
+ expect(formatter.send(:round_to, 12.25, 1)).to eq(12.3)
42
+ expect(formatter.send(:round_to, 12.25, 2)).to eq(12.25)
43
+ expect(formatter.send(:round_to, 12.25, 3)).to eq(12.25)
44
44
  end
45
45
  end
46
46
 
47
47
  describe "#parse_number" do
48
48
  it "should round and split the given number by decimal" do
49
- formatter.send(:parse_number, 12, :precision => 0).should == ["12"]
50
- formatter.send(:parse_number, 12.2, :precision => 0).should == ["12"]
51
- formatter.send(:parse_number, 12.5, :precision => 0).should == ["13"]
52
- formatter.send(:parse_number, 12.25, :precision => 1).should == ["12", "3"]
53
- formatter.send(:parse_number, 12.25, :precision => 2).should == ["12", "25"]
54
- formatter.send(:parse_number, 12.25, :precision => 3).should == ["12", "250"]
49
+ expect(formatter.send(:parse_number, 12, :precision => 0)).to eq(["12"])
50
+ expect(formatter.send(:parse_number, 12.2, :precision => 0)).to eq(["12"])
51
+ expect(formatter.send(:parse_number, 12.5, :precision => 0)).to eq(["13"])
52
+ expect(formatter.send(:parse_number, 12.25, :precision => 1)).to eq(["12", "3"])
53
+ expect(formatter.send(:parse_number, 12.25, :precision => 2)).to eq(["12", "25"])
54
+ expect(formatter.send(:parse_number, 12.25, :precision => 3)).to eq(["12", "250"])
55
55
  end
56
56
  end
57
57
 
@@ -62,33 +62,33 @@ describe NumberFormatter do
62
62
  end
63
63
 
64
64
  it "should format a basic integer" do
65
- format_number(12).should == "12"
65
+ expect(format_number(12)).to eq("12")
66
66
  end
67
67
 
68
68
  it "should format a basic decimal" do
69
- format_number(12.0).should == "12,0"
69
+ expect(format_number(12.0)).to eq("12,0")
70
70
  end
71
71
 
72
72
  context "should respect the :precision option" do
73
73
  it "formats with precision of 0" do
74
- format_number(12.1, :precision => 0).should == "12"
74
+ expect(format_number(12.1, :precision => 0)).to eq("12")
75
75
  end
76
76
 
77
77
  it "rounds and formats with precision of 1" do
78
- format_number(12.25, :precision => 1).should == "12,3"
78
+ expect(format_number(12.25, :precision => 1)).to eq("12,3")
79
79
  end
80
80
  end
81
81
 
82
82
  it "uses the length of the original decimal as the precision" do
83
- format_number(12.8543).should == "12,8543"
83
+ expect(format_number(12.8543)).to eq("12,8543")
84
84
  end
85
85
 
86
86
  it "formats an integer larger than 999" do
87
- format_number(1337).should == "1 337"
87
+ expect(format_number(1337)).to eq("1 337")
88
88
  end
89
89
 
90
90
  it "formats a decimal larger than 999.9" do
91
- format_number(1337.37).should == "1 337,37"
91
+ expect(format_number(1337.37)).to eq("1 337,37")
92
92
  end
93
93
  end
94
94
  end
@@ -17,18 +17,18 @@ describe PercentFormatter do
17
17
  it "should format the number correctly" do
18
18
  pattern = data_reader.pattern(number)
19
19
  tokens = tokenizer.tokenize(pattern)
20
- formatter.format(tokens, number).should == "12 %"
20
+ expect(formatter.format(tokens, number)).to eq("12 %")
21
21
  end
22
22
 
23
23
  it "should format negative numbers correctly" do
24
24
  pattern = data_reader.pattern(negative_number)
25
25
  tokens = tokenizer.tokenize(pattern)
26
- formatter.format(tokens, negative_number).should == "-12 %"
26
+ expect(formatter.format(tokens, negative_number)).to eq("-12 %")
27
27
  end
28
28
 
29
29
  it "should respect the :precision option" do
30
30
  pattern = data_reader.pattern(negative_number)
31
31
  tokens = tokenizer.tokenize(pattern)
32
- formatter.format(tokens, negative_number, :precision => 3).should match_normalized("-12,000 %")
32
+ expect(formatter.format(tokens, negative_number, :precision => 3)).to match_normalized("-12,000 %")
33
33
  end
34
34
  end
@@ -72,10 +72,10 @@ describe RbnfFormatter do
72
72
  failures[locale][group_name] ||= {}
73
73
  failures[locale][group_name][rule_set_name] ||= []
74
74
  failures[locale][group_name][rule_set_name] << number
75
- got.should == expected
75
+ expect(got).to eq(expected)
76
76
  end
77
77
  else
78
- got.should == expected
78
+ expect(got).to eq(expected)
79
79
  end
80
80
 
81
81
  end