localize_multi_digit 4.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -0
- data/test/test_localize_multi_digit.rb +56 -0
- metadata +3 -1
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require "i18n"
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/localize_multi_digit.rb')
|
6
|
+
|
7
|
+
class LocalizeMultiDigitTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
$ld = LocalizedDigits::Base.new()
|
10
|
+
[String, Fixnum, Float, Date, Time,NilClass].each do |item|
|
11
|
+
item.send(:include, LocalizeMultiDigit)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_work_for_empty_and_nil_value
|
15
|
+
I18n.locale = :en
|
16
|
+
assert_equal '', ''.to_ld
|
17
|
+
assert_equal '', nil.to_ld
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_work_for_default_english_digits
|
21
|
+
I18n.locale = :en
|
22
|
+
assert_equal "123", "123".to_ld
|
23
|
+
assert_equal "hola89cia00", "hola89cia00".to_ld
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_return_original_text_if_there_is_no_digit_even
|
27
|
+
I18n.locale = :en
|
28
|
+
assert_equal "Hello digit localizer!", "Hello digit localizer!".to_ld
|
29
|
+
|
30
|
+
I18n.locale = :bn
|
31
|
+
assert_equal "Hello digit localizer!", "Hello digit localizer!".to_ld
|
32
|
+
|
33
|
+
I18n.locale = :ar
|
34
|
+
assert_equal "Hello digit localizer!", "Hello digit localizer!".to_ld
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_work_for_arabic_digits
|
38
|
+
I18n.locale = :ar
|
39
|
+
assert_equal "Hello ١٢٣ World ٠٧٨", "Hello 123 World 078".to_ld
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_should_pass_for_numeric_float_value_on_non_english_language
|
43
|
+
I18n.locale = :bn
|
44
|
+
assert_equal "৪৫০", 450.to_ld
|
45
|
+
|
46
|
+
assert_equal "৪৫০.০৮৭", 450.087.to_ld
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_return_original_object_for_non_defined_language
|
50
|
+
I18n.locale = :err # err locale is not defined on localized_digits.yml file
|
51
|
+
assert_equal 123, 123.to_ld
|
52
|
+
assert_equal nil, nil.to_ld
|
53
|
+
assert_equal "Hello digit localizer!", "Hello digit localizer!".to_ld
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localize_multi_digit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,6 +21,8 @@ files:
|
|
21
21
|
- lib/generators/localize_multi_digit.rb
|
22
22
|
- lib/generators/localize_multi_digit_generator.rb
|
23
23
|
- lib/generators/localized_digits.yml
|
24
|
+
- Rakefile
|
25
|
+
- test/test_localize_multi_digit.rb
|
24
26
|
homepage:
|
25
27
|
licenses: []
|
26
28
|
post_install_message:
|