Skip to content

Some assertions I found helpfull when working with I18n and Test::Unit. If anyone has a better repos, let me know.

Notifications You must be signed in to change notification settings

tomlea/assert_i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AssertI18n

A collection of I18n assertions I use in daily life.

Assertions Provided:

  • assert_no_missing_translations – Checks that no missing translation errors occurred inside the block
  • assert_all_locales_have_all_translations_available_to_the_default_locale – Makes sure all your locale translations files are in sync with your default locale.
  • assert_localized_file_availability – Checks that a file is exists in all available_locales.

Helpers Provided:

  • each_locale – Iterates over each locale, passing in the locale as a parameter to the block.
  • with_each_locale – Iterates over each locale, setting `I18n.locale` and running the block for each locale in turn.

Usage:

assert_no_missing_translations:

class FooTest < Test::Unit::TestCase include AssertI18n::TestHelper def test_should_have_translations_for_the_word_foo assert_no_missing_translations do I18n.t(:foo) end end def test_should_have_all_translations_needed_for_rendering_email assert_no_missing_translations do MyApp::EMailRenderer.new(:foo).render! end end end

assert_all_locales_have_all_translations_available_to_the_default_locale

class PredeployTest < Test::Unit::TestCase include AssertI18n::TestHelper def test_all_locales_have_all_translations_available_to_the_default_locale assert_all_locales_have_all_translations_available_to_the_default_locale end end

assert_localized_file_availability

class PredeployTest < Test::Unit::TestCase include AssertI18n::TestHelper def test_we_have_our_logo_in_all_locales assert_localized_file_availability(“#{Rails.root}/public/images/logo_%s.png”) end end

each_locale

class PredeployTest < Test::Unit::TestCase include AssertI18n::TestHelper def test_should_foo_for_all_locales each_locale do |locale| assert_some_foo_is_ok_in(locale) end end end

with_each_locale

class PredeployTest < Test::Unit::TestCase include AssertI18n::TestHelper def test_should_foo_for_all_locales with_each_locale do assert_that_something_still_works end end end

About

Some assertions I found helpfull when working with I18n and Test::Unit. If anyone has a better repos, let me know.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages