i18n_plus 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2134e91545ff3bc1a416b49b597b960874242ada
4
+ data.tar.gz: 00b35a09990f9e5e7f8b7bef617c159c05282489
5
+ SHA512:
6
+ metadata.gz: 86e47aef9e84474b58b7c1b846f13914d2705566f956c50acc724bb71669f1aaf6cc823fc22255ecb1e08e581f9651a5c0f7a987e7e84a2902f1453cf8badbe1
7
+ data.tar.gz: e1fe7080009999952ae974de5a277e4f524777c9c11b705254b12c9e52dabe2216e5065e224ff7ee116f67bb8bb521295551ec5a89d51b18098a759941eb80a0
@@ -1,3 +1,8 @@
1
+ # 0.2.0, release 2013-08-06
2
+
3
+ * Rails 4 updates
4
+ * General gem updates, e.g. Mocha
5
+
1
6
  # 0.1.5, release 2012-06-19
2
7
 
3
8
  * Fixed NOrway as a language
@@ -19,7 +19,13 @@ module ActionView
19
19
  module Helpers
20
20
  module FormOptionsHelper
21
21
  def country_select(object, method, priority_country_codes = nil, options = {}, html_options = {})
22
- InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_country_codes, options, html_options)
22
+ tag = if defined?(ActionView::Helpers::InstanceTag) &&
23
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
24
+ InstanceTag.new(object, method, self, options.delete(:object))
25
+ else
26
+ CountrySelect.new(object, method, self, options)
27
+ end
28
+ tag.to_country_select_tag(priority_country_codes, options, html_options)
23
29
  end
24
30
 
25
31
  def country_options_for_select(selected = nil, *priority_country_codes)
@@ -36,7 +42,7 @@ module ActionView
36
42
  end
37
43
  end
38
44
 
39
- class InstanceTag
45
+ module ToCountrySelectTag
40
46
  def to_country_select_tag(priority_country_codes, options, html_options)
41
47
  html_options = html_options.stringify_keys
42
48
  add_default_name_and_id(html_options)
@@ -46,6 +52,17 @@ module ActionView
46
52
  end
47
53
  end
48
54
 
55
+ if defined?(ActionView::Helpers::InstanceTag) &&
56
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
57
+ class InstanceTag
58
+ include ToCountrySelectTag
59
+ end
60
+ else
61
+ class CountrySelect < Tags::Base
62
+ include ToCountrySelectTag
63
+ end
64
+ end
65
+
49
66
  class FormBuilder
50
67
  def country_select(method, priority_country_codes = nil, options = {}, html_options = {})
51
68
  @template.country_select(@object_name, method, priority_country_codes, options.merge(:object => @object), html_options)
@@ -18,8 +18,14 @@ end
18
18
  module ActionView
19
19
  module Helpers
20
20
  module FormOptionsHelper
21
- def currency_select(object, method, priority_country_codes = nil, options = {}, html_options = {})
22
- InstanceTag.new(object, method, self, options.delete(:object)).to_currency_select_tag(priority_country_codes, options, html_options)
21
+ def currency_select(object, method, priority_currency_codes = nil, options = {}, html_options = {})
22
+ tag = if defined?(ActionView::Helpers::InstanceTag) &&
23
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
24
+ InstanceTag.new(object, method, self, options.delete(:object))
25
+ else
26
+ CurrencySelect.new(object, method, self, options)
27
+ end
28
+ tag.to_currency_select_tag(priority_currency_codes, options, html_options)
23
29
  end
24
30
 
25
31
  def currency_options_for_select(selected = nil, *priority_currency_codes)
@@ -36,7 +42,7 @@ module ActionView
36
42
  end
37
43
  end
38
44
 
39
- class InstanceTag
45
+ module ToCurrencySelectTag
40
46
  def to_currency_select_tag(priority_currency_codes, options, html_options)
41
47
  html_options = html_options.stringify_keys
42
48
  add_default_name_and_id(html_options)
@@ -46,6 +52,17 @@ module ActionView
46
52
  end
47
53
  end
48
54
 
55
+ if defined?(ActionView::Helpers::InstanceTag) &&
56
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
57
+ class InstanceTag
58
+ include ToCurrencySelectTag
59
+ end
60
+ else
61
+ class CurrencySelect < Tags::Base
62
+ include ToCurrencySelectTag
63
+ end
64
+ end
65
+
49
66
  class FormBuilder
50
67
  def currency_select(method, priority_currency_codes = nil, options = {}, html_options = {})
51
68
  @template.currency_select(@object_name, method, priority_currency_codes, options.merge(:object => @object), html_options)
@@ -19,7 +19,14 @@ module ActionView
19
19
  module Helpers
20
20
  module FormOptionsHelper
21
21
  def language_select(object, method, priority_language_codes = nil, options = {}, html_options = {})
22
- InstanceTag.new(object, method, self, options.delete(:object)).to_language_select_tag(priority_language_codes, options, html_options)
22
+ tag = if defined?(ActionView::Helpers::InstanceTag) &&
23
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
24
+ InstanceTag.new(object, method, self, options.delete(:object))
25
+ else
26
+ LanguageSelect.new(object, method, self, options)
27
+ end
28
+
29
+ tag.to_language_select_tag(priority_language_codes, options, html_options)
23
30
  end
24
31
 
25
32
  def language_options_for_select(selected = nil, *priority_language_codes)
@@ -36,7 +43,7 @@ module ActionView
36
43
  end
37
44
  end
38
45
 
39
- class InstanceTag
46
+ module ToLanguageSelectTag
40
47
  def to_language_select_tag(priority_language_codes, options, html_options)
41
48
  html_options = html_options.stringify_keys
42
49
  add_default_name_and_id(html_options)
@@ -46,6 +53,17 @@ module ActionView
46
53
  end
47
54
  end
48
55
 
56
+ if defined?(ActionView::Helpers::InstanceTag) &&
57
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
58
+ class InstanceTag
59
+ include ToLanguageSelectTag
60
+ end
61
+ else
62
+ class LanguageSelect < Tags::Base
63
+ include ToLanguageSelectTag
64
+ end
65
+ end
66
+
49
67
  class FormBuilder
50
68
  def language_select(method, priority_language_codes = nil, options = {}, html_options = {})
51
69
  @template.language_select(@object_name, method, priority_language_codes, options.merge(:object => @object), html_options)
@@ -19,7 +19,13 @@ module ActionView
19
19
  module Helpers
20
20
  module FormOptionsHelper
21
21
  def locale_select(object, method, priority_locale_codes = nil, options = {}, html_options = {})
22
- InstanceTag.new(object, method, self, options.delete(:object)).to_locale_select_tag(priority_locale_codes, options, html_options)
22
+ tag = if defined?(ActionView::Helpers::InstanceTag) &&
23
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
24
+ InstanceTag.new(object, method, self, options.delete(:object))
25
+ else
26
+ LocaleSelect.new(object, method, self, options)
27
+ end
28
+ tag.to_locale_select_tag(priority_locale_codes, options, html_options)
23
29
  end
24
30
 
25
31
  def locale_options_for_select(selected = nil, *priority_locale_codes)
@@ -36,7 +42,7 @@ module ActionView
36
42
  end
37
43
  end
38
44
 
39
- class InstanceTag
45
+ module ToLocaleSelectTag
40
46
  def to_locale_select_tag(priority_locale_codes, options, html_options)
41
47
  html_options = html_options.stringify_keys
42
48
  add_default_name_and_id(html_options)
@@ -46,6 +52,17 @@ module ActionView
46
52
  end
47
53
  end
48
54
 
55
+ if defined?(ActionView::Helpers::InstanceTag) &&
56
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
57
+ class InstanceTag
58
+ include ToLocaleSelectTag
59
+ end
60
+ else
61
+ class LocaleSelect < Tags::Base
62
+ include ToLocaleSelectTag
63
+ end
64
+ end
65
+
49
66
  class FormBuilder
50
67
  def locale_select(method, priority_locale_codes = nil, options = {}, html_options = {})
51
68
  @template.locale_select(@object_name, method, priority_locale_codes, options.merge(:object => @object), html_options)
@@ -19,7 +19,13 @@ module ActionView
19
19
  module Helpers
20
20
  module FormOptionsHelper
21
21
  def state_select(object, method, country_code, options = {}, html_options = {})
22
- InstanceTag.new(object, method, self, options.delete(:object)).to_state_select_tag(country_code, options, html_options)
22
+ tag = if defined?(ActionView::Helpers::InstanceTag) &&
23
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
24
+ InstanceTag.new(object, method, self, options.delete(:object))
25
+ else
26
+ StateSelect.new(object, method, self, options)
27
+ end
28
+ tag.to_state_select_tag(country_code, options, html_options)
23
29
  end
24
30
 
25
31
  def state_options_for_select(country_code, selected = nil)
@@ -28,7 +34,7 @@ module ActionView
28
34
  end
29
35
  end
30
36
 
31
- class InstanceTag
37
+ module ToStateSelectTag
32
38
  def to_state_select_tag(country_code, options, html_options)
33
39
  html_options = html_options.stringify_keys
34
40
  add_default_name_and_id(html_options)
@@ -38,6 +44,17 @@ module ActionView
38
44
  end
39
45
  end
40
46
 
47
+ if defined?(ActionView::Helpers::InstanceTag) &&
48
+ ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
49
+ class InstanceTag
50
+ include ToStateSelectTag
51
+ end
52
+ else
53
+ class StateSelect < Tags::Base
54
+ include ToStateSelectTag
55
+ end
56
+ end
57
+
41
58
  class FormBuilder
42
59
  def state_select(method, country_code, options = {}, html_options = {})
43
60
  @template.country_select(@object_name, method, country_code, options.merge(:object => @object), html_options)
@@ -1,3 +1,3 @@
1
1
  module I18nPlus
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,105 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'test_helper'
4
+
5
+ class CountryTest < ActiveSupport::TestCase
6
+ include ActionView::Helpers::FormOptionsHelper
7
+
8
+ setup do
9
+ @account = stub(:country => 'DE', :to_s => 'account')
10
+ end
11
+
12
+ test "should have countries" do
13
+ assert_not_nil I18nPlus.countries
14
+ assert !I18nPlus.countries.empty?
15
+ end
16
+
17
+ test "should return country name in German with I18n.locale set" do
18
+ I18n.locale = :de
19
+ assert_equal "Großbritannien", I18nPlus.country_name('GB')
20
+ end
21
+
22
+ test "should return country name in English with I18n.locale set" do
23
+ I18n.locale = :en
24
+ assert_equal "United Kingdom", I18nPlus.country_name('GB')
25
+ end
26
+
27
+ test "should return country name in German with locale option" do
28
+ assert_equal "Großbritannien", I18nPlus.country_name('GB', :locale => :de)
29
+ end
30
+
31
+ test "should return country name in English with locale option" do
32
+ assert_equal "United Kingdom", I18nPlus.country_name('GB', :locale => :en)
33
+ end
34
+
35
+ test "should return country name in German as locale option has precedence over I18n.locale" do
36
+ I18n.locale = :en
37
+ assert_equal "Großbritannien", I18nPlus.country_name('GB', :locale => :de)
38
+ I18n.locale = :de
39
+ assert_equal "United Kingdom", I18nPlus.country_name('GB', :locale => :en)
40
+ end
41
+
42
+ test "should return country options for German" do
43
+ I18n.locale = :de
44
+
45
+ if ActiveSupport::VERSION::STRING < '4.0'
46
+ match = /<option value="DE" selected="selected">Deutschland<\/option>/
47
+ else
48
+ match = /<option selected="selected" value="DE">Deutschland<\/option>/
49
+ end
50
+ assert_match match, country_options_for_select('DE').gsub(/\n/, '')
51
+ end
52
+
53
+ test "should return country options for English" do
54
+ I18n.locale = :en
55
+
56
+ if ActiveSupport::VERSION::STRING < '4.0'
57
+ match = /<option value="DE" selected="selected">Germany<\/option>/
58
+ else
59
+ match = /<option selected="selected" value="DE">Germany<\/option>/
60
+ end
61
+ assert_match match, country_options_for_select('DE').gsub(/\n/, '')
62
+ end
63
+
64
+ test "should return country options with priority countries for English" do
65
+ I18n.locale = :en
66
+
67
+ if ActiveSupport::VERSION::STRING < '4.0'
68
+ match = /<option value="DE" selected="selected">Germany<\/option><option value="" disabled="disabled">----------<\/option>/
69
+ else
70
+ match = /<option selected="selected" value="DE">Germany<\/option><option value="" disabled="disabled">----------<\/option>/
71
+ end
72
+ assert_match match, country_options_for_select('DE', 'DE').gsub(/\n/, '')
73
+ end
74
+
75
+ test "should return country options with multiple priority countries for English" do
76
+ I18n.locale = :en
77
+
78
+ if ActiveSupport::VERSION::STRING < '4.0'
79
+ match = /<option value="DE" selected="selected">Germany<\/option><option value=\"GB\">United Kingdom<\/option><option value="" disabled="disabled">----------<\/option>/
80
+ else
81
+ match = /<option selected="selected" value="DE">Germany<\/option><option value=\"GB\">United Kingdom<\/option><option value="" disabled="disabled">----------<\/option>/
82
+ end
83
+ assert_match match, country_options_for_select('DE', 'DE', 'GB').gsub(/\n/, '')
84
+ end
85
+
86
+ test "should return country_select" do
87
+ I18n.locale = :en
88
+
89
+ if ActiveSupport::VERSION::STRING < '4.0'
90
+ match = /<select id="account_country" name="account\[country\]"><option value="DE" selected="selected">Germany<\/option><option value="" disabled="disabled">----------<\/option>/
91
+ else
92
+ match = /<select id="account_country" name="account\[country\]"><option selected="selected" value="DE">Germany<\/option><option value="" disabled="disabled">----------<\/option>/
93
+ end
94
+ assert_match match, country_select(@account, :country, 'DE').gsub(/\n/, '')
95
+ end
96
+
97
+ test "should return norway" do
98
+ # NO is a special case in YAML and yields false
99
+ I18n.locale = :de
100
+ assert_equal "Norwegen", I18nPlus.country_name('NO')
101
+ I18n.locale = :en
102
+ assert_equal "Norway", I18nPlus.country_name('NO')
103
+ end
104
+
105
+ end
@@ -0,0 +1,71 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'test_helper'
4
+
5
+ class CurrencyTest < ActiveSupport::TestCase
6
+ include ActionView::Helpers::FormOptionsHelper
7
+
8
+ setup do
9
+ @account = stub(:currency => 'EUR', :to_s => 'account')
10
+ end
11
+
12
+ test "should have currencies" do
13
+ assert_not_nil I18nPlus.currencies
14
+ assert !I18nPlus.currencies.empty?
15
+ end
16
+
17
+ test "should return currency options for German" do
18
+ I18n.locale = :de
19
+
20
+ if ActiveSupport::VERSION::STRING < '4.0'
21
+ match = /<option value="EUR" selected="selected">EUR \(€\)<\/option>/
22
+ else
23
+ match = /<option selected="selected" value="EUR">EUR \(€\)<\/option>/
24
+ end
25
+ assert_match match, currency_options_for_select('EUR').gsub(/\n/, '')
26
+ end
27
+
28
+ test "should return currency options for English" do
29
+ I18n.locale = :en
30
+
31
+ if ActiveSupport::VERSION::STRING < '4.0'
32
+ match = /<option value="EUR" selected="selected">EUR \(€\)<\/option>/
33
+ else
34
+ match = /<option selected="selected" value="EUR">EUR \(€\)<\/option>/
35
+ end
36
+ assert_match match, currency_options_for_select('EUR').gsub(/\n/, '')
37
+ end
38
+
39
+ test "should return currency options with priority currencies for English" do
40
+ I18n.locale = :en
41
+
42
+ if ActiveSupport::VERSION::STRING < '4.0'
43
+ match = /<option value="EUR" selected="selected">EUR \(€\)<\/option><option value="" disabled="disabled">----------<\/option>/
44
+ else
45
+ match = /<option selected="selected" value="EUR">EUR \(€\)<\/option><option value="" disabled="disabled">----------<\/option>/
46
+ end
47
+ assert_match match, currency_options_for_select('EUR', 'EUR').gsub(/\n/, '')
48
+ end
49
+
50
+ test "should return currency options with multiple priority currencies for English" do
51
+ I18n.locale = :en
52
+
53
+ if ActiveSupport::VERSION::STRING < '4.0'
54
+ match = /<option value="EUR" selected="selected">EUR \(€\)<\/option><option value=\"USD\">USD \(\$\)<\/option><option value="" disabled="disabled">----------<\/option>/
55
+ else
56
+ match = /<option selected="selected" value="EUR">EUR \(€\)<\/option><option value=\"USD\">USD \(\$\)<\/option><option value="" disabled="disabled">----------<\/option>/
57
+ end
58
+ assert_match match, currency_options_for_select('EUR', 'EUR', 'USD').gsub(/\n/, '')
59
+ end
60
+
61
+ test "should return currency_select" do
62
+ I18n.locale = :en
63
+
64
+ if ActiveSupport::VERSION::STRING < '4.0'
65
+ match = /<select id="account_currency" name="account\[currency\]"><option value="EUR" selected="selected">EUR \(€\)<\/option><option value="" disabled="disabled">----------<\/option>/
66
+ else
67
+ match = /<select id="account_currency" name="account\[currency\]"><option selected="selected" value="EUR">EUR \(€\)<\/option><option value="" disabled="disabled">----------<\/option>/
68
+ end
69
+ assert_match match, currency_select(@account, :currency, 'EUR').gsub(/\n/, '')
70
+ end
71
+ end
@@ -0,0 +1,78 @@
1
+ require 'test_helper'
2
+
3
+ class LanguageTest < ActiveSupport::TestCase
4
+ include ActionView::Helpers::FormOptionsHelper
5
+
6
+ setup do
7
+ @account = stub(:language => 'DE', :to_s => 'account')
8
+ end
9
+
10
+ test "should have languages" do
11
+ assert_not_nil I18nPlus.languages
12
+ assert !I18nPlus.languages.empty?
13
+ end
14
+
15
+ test "should return language options for German" do
16
+ I18n.locale = :de
17
+
18
+ if ActiveSupport::VERSION::STRING < '4.0'
19
+ match = /<option value="DE" selected="selected">Deutsch<\/option>/
20
+ else
21
+ match = /<option selected="selected" value="DE">Deutsch<\/option>/
22
+ end
23
+ assert_match match, language_options_for_select('DE').gsub(/\n/, '')
24
+ end
25
+
26
+ test "should return language options for English" do
27
+ I18n.locale = :en
28
+
29
+ if ActiveSupport::VERSION::STRING < '4.0'
30
+ match = /<option value="DE" selected="selected">German<\/option>/
31
+ else
32
+ match = /<option selected="selected" value="DE">German<\/option>/
33
+ end
34
+ assert_match match, language_options_for_select('DE').gsub(/\n/, '')
35
+ end
36
+
37
+ test "should return language options with priority languages for English" do
38
+ I18n.locale = :en
39
+
40
+ if ActiveSupport::VERSION::STRING < '4.0'
41
+ match = /<option value="DE" selected="selected">German<\/option><option value="" disabled="disabled">----------<\/option>/
42
+ else
43
+ match = /<option selected="selected" value="DE">German<\/option><option value="" disabled="disabled">----------<\/option>/
44
+ end
45
+ assert_match match, language_options_for_select('DE', 'DE').gsub(/\n/, '')
46
+ end
47
+
48
+ test "should return language options with multiple priority languages for English" do
49
+ I18n.locale = :en
50
+
51
+ if ActiveSupport::VERSION::STRING < '4.0'
52
+ match = /<option value="DE" selected="selected">German<\/option><option value=\"EN\">English<\/option><option value="" disabled="disabled">----------<\/option>/
53
+ else
54
+ match = /<option selected="selected" value="DE">German<\/option><option value=\"EN\">English<\/option><option value="" disabled="disabled">----------<\/option>/
55
+ end
56
+ assert_match match, language_options_for_select('DE', 'DE', 'EN').gsub(/\n/, '')
57
+ end
58
+
59
+ test "should return language_select" do
60
+ I18n.locale = :en
61
+
62
+ if ActiveSupport::VERSION::STRING < '4.0'
63
+ match = /<select id="account_language" name="account\[language\]"><option value="DE" selected="selected">German<\/option><option value="" disabled="disabled">----------<\/option>/
64
+ else
65
+ match = /<select id="account_language" name="account\[language\]"><option selected="selected" value="DE">German<\/option><option value="" disabled="disabled">----------<\/option>/
66
+ end
67
+ assert_match match, language_select(@account, :language, 'DE').gsub(/\n/, '')
68
+ end
69
+
70
+ test "should return Norwegian" do
71
+ # NO is a special case in YAML and yields false
72
+ I18n.locale = :de
73
+ assert_equal "Norwegisch", I18nPlus.language_name('NO')
74
+ I18n.locale = :en
75
+ assert_equal "Norwegian", I18nPlus.language_name('NO')
76
+ end
77
+
78
+ end
@@ -0,0 +1,69 @@
1
+ require 'test_helper'
2
+
3
+ class LocaleTest < ActiveSupport::TestCase
4
+ include ActionView::Helpers::FormOptionsHelper
5
+
6
+ setup do
7
+ @account = stub(:locale => 'de-DE', :to_s => 'account')
8
+ end
9
+
10
+ test "should have locales" do
11
+ assert_not_nil I18nPlus.locales
12
+ assert !I18nPlus.locales.empty?
13
+ end
14
+
15
+ test "should return locale options for German" do
16
+ I18n.locale = :de
17
+
18
+ if ActiveSupport::VERSION::STRING < '4.0'
19
+ match = /<option value="de-DE" selected="selected">Deutsch \(Deutschland\)<\/option>/
20
+ else
21
+ match = /<option selected="selected" value="de-DE">Deutsch \(Deutschland\)<\/option>/
22
+ end
23
+ assert_match match, locale_options_for_select('de-DE').gsub(/\n/, '')
24
+ end
25
+
26
+ test "should return locale options for English" do
27
+ I18n.locale = :en
28
+
29
+ if ActiveSupport::VERSION::STRING < '4.0'
30
+ match = /<option value="de-DE" selected="selected">German \(Germany\)<\/option>/
31
+ else
32
+ match = /<option selected="selected" value="de-DE">German \(Germany\)<\/option>/
33
+ end
34
+ assert_match match, locale_options_for_select('de-DE').gsub(/\n/, '')
35
+ end
36
+
37
+ test "should return locale options with priority locale for English" do
38
+ I18n.locale = :en
39
+
40
+ if ActiveSupport::VERSION::STRING < '4.0'
41
+ match = /<option value="de-DE" selected="selected">German \(Germany\)<\/option><option value="" disabled="disabled">----------<\/option>/
42
+ else
43
+ match = /<option selected="selected" value="de-DE">German \(Germany\)<\/option><option value="" disabled="disabled">----------<\/option>/
44
+ end
45
+ assert_match match, locale_options_for_select('de-DE', 'de-DE').gsub(/\n/, '')
46
+ end
47
+
48
+ test "should return locale options with multiple priority locales for English" do
49
+ I18n.locale = :en
50
+
51
+ if ActiveSupport::VERSION::STRING < '4.0'
52
+ match = /<option value="de-DE" selected="selected">German \(Germany\)<\/option><option value=\"en-GB\">English \(United Kingdom\)<\/option><option value="" disabled="disabled">----------<\/option>/
53
+ else
54
+ match = /<option selected="selected" value="de-DE">German \(Germany\)<\/option><option value=\"en-GB\">English \(United Kingdom\)<\/option><option value="" disabled="disabled">----------<\/option>/
55
+ end
56
+ assert_match match, locale_options_for_select('de-DE', 'de-DE', 'en-GB').gsub(/\n/, '')
57
+ end
58
+
59
+ test "should return locale_select" do
60
+ I18n.locale = :en
61
+
62
+ if ActiveSupport::VERSION::STRING < '4.0'
63
+ match = /<select id="account_locale" name="account\[locale\]"><option value="de-DE" selected="selected">German \(Germany\)<\/option><option value="" disabled="disabled">----------<\/option>/
64
+ else
65
+ match = /<select id="account_locale" name="account\[locale\]"><option selected="selected" value="de-DE">German \(Germany\)<\/option><option value="" disabled="disabled">----------<\/option>/
66
+ end
67
+ assert_match match, locale_select(@account, :locale, 'de-DE').gsub(/\n/, '')
68
+ end
69
+ end
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class StateTest < ActiveSupport::TestCase
4
+ include ActionView::Helpers::FormOptionsHelper
5
+
6
+ setup do
7
+ @account = stub(:country => 'DE', :state => 'BY', :to_s => 'account')
8
+ end
9
+
10
+ test "should have states" do
11
+ assert_not_nil I18nPlus.states('DE')
12
+ assert !I18nPlus.states('DE').empty?
13
+ end
14
+
15
+ test "should return states of Germany in German" do
16
+ I18n.locale = :de
17
+
18
+ if ActiveSupport::VERSION::STRING < '4.0'
19
+ match = /<option value="BY" selected="selected">Bayern<\/option>/
20
+ else
21
+ match = /<option selected="selected" value="BY">Bayern<\/option>/
22
+ end
23
+ assert_match match, state_options_for_select('DE', 'BY').gsub(/\n/, '')
24
+ end
25
+
26
+ test "should return states of Germany in English" do
27
+ I18n.locale = :en
28
+ if ActiveSupport::VERSION::STRING < '4.0'
29
+ match = /<option value="BY" selected="selected">Bavaria<\/option>/
30
+ else
31
+ match = /<option selected="selected" value="BY">Bavaria<\/option>/
32
+ end
33
+ assert_match match, state_options_for_select('DE', 'BY').gsub(/\n/, '')
34
+ end
35
+
36
+ test "should return state_select in English" do
37
+ I18n.locale = :en
38
+ assert_not_nil results = state_select(@account, :state, 'DE').gsub(/\n/, '')
39
+
40
+ assert_match /<select id="account_state" name="account\[state\]">/, results
41
+
42
+ if ActiveSupport::VERSION::STRING < '4.0'
43
+ match = /<option value="BY" selected="selected">Bavaria<\/option>/
44
+ else
45
+ match = /<option selected="selected" value="BY">Bavaria<\/option>/
46
+ end
47
+ assert_match match, results
48
+ end
49
+ end
metadata CHANGED
@@ -1,22 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Oliver Eilhard
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-19 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.1.0
22
20
  - - <
@@ -25,9 +23,8 @@ dependencies:
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: 1.1.0
33
30
  - - <
@@ -36,99 +33,101 @@ dependencies:
36
33
  - !ruby/object:Gem::Dependency
37
34
  name: activesupport
38
35
  requirement: !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
- - - ! '>='
37
+ - - '>='
42
38
  - !ruby/object:Gem::Version
43
- version: 3.0.0
39
+ version: '0'
44
40
  type: :runtime
45
41
  prerelease: false
46
42
  version_requirements: !ruby/object:Gem::Requirement
47
- none: false
48
43
  requirements:
49
- - - ! '>='
44
+ - - '>='
50
45
  - !ruby/object:Gem::Version
51
- version: 3.0.0
46
+ version: '0'
52
47
  - !ruby/object:Gem::Dependency
53
48
  name: actionpack
54
49
  requirement: !ruby/object:Gem::Requirement
55
- none: false
56
50
  requirements:
57
- - - ! '>='
51
+ - - '>='
58
52
  - !ruby/object:Gem::Version
59
- version: 3.0.0
53
+ version: '0'
60
54
  type: :runtime
61
55
  prerelease: false
62
56
  version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
57
  requirements:
65
- - - ! '>='
58
+ - - '>='
66
59
  - !ruby/object:Gem::Version
67
- version: 3.0.0
60
+ version: '0'
68
61
  - !ruby/object:Gem::Dependency
69
62
  name: bundler
70
63
  requirement: !ruby/object:Gem::Requirement
71
- none: false
72
64
  requirements:
73
65
  - - ~>
74
66
  - !ruby/object:Gem::Version
75
- version: '1.0'
67
+ version: 1.3.5
76
68
  type: :development
77
69
  prerelease: false
78
70
  version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
71
  requirements:
81
72
  - - ~>
82
73
  - !ruby/object:Gem::Version
83
- version: '1.0'
74
+ version: 1.3.5
84
75
  - !ruby/object:Gem::Dependency
85
76
  name: rdoc
86
77
  requirement: !ruby/object:Gem::Requirement
87
- none: false
88
78
  requirements:
89
79
  - - ~>
90
80
  - !ruby/object:Gem::Version
91
- version: '2.5'
81
+ version: 2.5.3
92
82
  type: :development
93
83
  prerelease: false
94
84
  version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
85
  requirements:
97
86
  - - ~>
98
87
  - !ruby/object:Gem::Version
99
- version: '2.5'
88
+ version: 2.5.3
89
+ - !ruby/object:Gem::Dependency
90
+ name: mocha
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: 0.14.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: 0.14.0
100
103
  - !ruby/object:Gem::Dependency
101
104
  name: rake
102
105
  requirement: !ruby/object:Gem::Requirement
103
- none: false
104
106
  requirements:
105
- - - ! '>='
107
+ - - '>='
106
108
  - !ruby/object:Gem::Version
107
- version: '0.9'
109
+ version: '0'
108
110
  type: :development
109
111
  prerelease: false
110
112
  version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
113
  requirements:
113
- - - ! '>='
114
+ - - '>='
114
115
  - !ruby/object:Gem::Version
115
- version: '0.9'
116
+ version: '0'
116
117
  - !ruby/object:Gem::Dependency
117
- name: mocha
118
+ name: minitest
118
119
  requirement: !ruby/object:Gem::Requirement
119
- none: false
120
120
  requirements:
121
- - - ! '>='
121
+ - - '>='
122
122
  - !ruby/object:Gem::Version
123
- version: 0.11.4
123
+ version: '0'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
- none: false
128
127
  requirements:
129
- - - ! '>='
128
+ - - '>='
130
129
  - !ruby/object:Gem::Version
131
- version: 0.11.4
130
+ version: '0'
132
131
  description: A library for i18n of countries, states, currencies, and locales.
133
132
  email:
134
133
  - oliver.eilhard@gmail.com
@@ -154,29 +153,38 @@ files:
154
153
  - CHANGELOG.md
155
154
  - LICENSE
156
155
  - README.md
156
+ - test/country_test.rb
157
+ - test/currency_test.rb
158
+ - test/language_test.rb
159
+ - test/locale_test.rb
160
+ - test/state_test.rb
157
161
  homepage: http://github.com/olivere/i18n_plus
158
162
  licenses: []
163
+ metadata: {}
159
164
  post_install_message:
160
165
  rdoc_options:
161
166
  - --charset=UTF-8
162
167
  require_paths:
163
168
  - lib
164
169
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
170
  requirements:
167
- - - ! '>='
171
+ - - '>='
168
172
  - !ruby/object:Gem::Version
169
173
  version: '0'
170
174
  required_rubygems_version: !ruby/object:Gem::Requirement
171
- none: false
172
175
  requirements:
173
- - - ! '>='
176
+ - - '>='
174
177
  - !ruby/object:Gem::Version
175
178
  version: 1.3.6
176
179
  requirements: []
177
180
  rubyforge_project:
178
- rubygems_version: 1.8.23
181
+ rubygems_version: 2.0.3
179
182
  signing_key:
180
- specification_version: 3
183
+ specification_version: 4
181
184
  summary: A library for i18n of countries, states, currencies, and locales.
182
- test_files: []
185
+ test_files:
186
+ - test/country_test.rb
187
+ - test/currency_test.rb
188
+ - test/language_test.rb
189
+ - test/locale_test.rb
190
+ - test/state_test.rb