Module: Tests::Backend::Api::Translation
- Included in:
- I18nChainBackendApiTranslateTest, I18nFallbacksBackendApiTranslateTest, I18nPluralizationBackendApiTranslateTest, I18nSimpleBackendApiTranslateTest
- Defined in:
- lib/vendor/i18n/test/api/translation.rb
Instance Method Summary collapse
- #test_given_no_keys_it_returns_the_default ⇒ Object
- #test_translate_an_array_of_keys_translates_all_of_them ⇒ Object
- #test_translate_default_with_scope_stays_in_scope_when_looking_up_the_symbol ⇒ Object
- #test_translate_given_a_symbol_as_a_default_translates_the_symbol ⇒ Object
- #test_translate_given_an_array_as_default_uses_the_first_match ⇒ Object
- #test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data ⇒ Object
- #test_translate_given_nil_as_a_locale_raises_an_argument_error ⇒ Object
- #test_translate_with_a_missing_key_and_no_default_raises_missing_translation_data ⇒ Object
- #translate(key, options = {}) ⇒ Object
Instance Method Details
#test_given_no_keys_it_returns_the_default ⇒ Object
11 12 13 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 11 def test_given_no_keys_it_returns_the_default assert_equal 'default', translate(nil, :default => 'default') end |
#test_translate_an_array_of_keys_translates_all_of_them ⇒ Object
33 34 35 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 33 def test_translate_an_array_of_keys_translates_all_of_them assert_equal %w(bar baz), translate([:bar, :baz], :scope => [:foo]) end |
#test_translate_default_with_scope_stays_in_scope_when_looking_up_the_symbol ⇒ Object
19 20 21 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 19 def test_translate_default_with_scope_stays_in_scope_when_looking_up_the_symbol assert_equal 'bar', translate(:missing, :default => :bar, :scope => :foo) end |
#test_translate_given_a_symbol_as_a_default_translates_the_symbol ⇒ Object
15 16 17 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 15 def test_translate_given_a_symbol_as_a_default_translates_the_symbol assert_equal 'bar', translate(nil, :default => :'foo.bar') end |
#test_translate_given_an_array_as_default_uses_the_first_match ⇒ Object
23 24 25 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 23 def test_translate_given_an_array_as_default_uses_the_first_match assert_equal 'bar', translate(:does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar]) end |
#test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data ⇒ Object
27 28 29 30 31 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 27 def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data assert_raises I18n::MissingTranslationData do translate(:does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3]) end end |
#test_translate_given_nil_as_a_locale_raises_an_argument_error ⇒ Object
43 44 45 46 47 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 43 def test_translate_given_nil_as_a_locale_raises_an_argument_error assert_raises(I18n::InvalidLocale) do I18n.backend.translate(nil, :bar) end end |
#test_translate_with_a_missing_key_and_no_default_raises_missing_translation_data ⇒ Object
37 38 39 40 41 |
# File 'lib/vendor/i18n/test/api/translation.rb', line 37 def test_translate_with_a_missing_key_and_no_default_raises_missing_translation_data assert_raises(I18n::MissingTranslationData) do translate(:missing) end end |