Module: I18nCheckTranslations::RSpec

Defined in:
lib/i18n_check_translations_rspec.rb

Class Method Summary collapse

Class Method Details

.check_for_missing_translations(example, basic_locale) ⇒ Object

Dynamically creates the examples that will check for the keys. One example for each key.

Parameters:

  • example (RSpec::Core::ExampleGroup)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/i18n_check_translations_rspec.rb', line 7

def self.check_for_missing_translations(example, basic_locale)
  I18n.available_locales.reject {|al| al == basic_locale}.each do |available_locale|
    results = I18nCheckTranslations.check(basic_locale, available_locale)
    results.each do |key, value|
      test_name = "for key: #{key}, in localization_file: #{value[:localization_file]}"
      example.it test_name do
        expect(value[:translation].start_with?('translation missing')).to be_false
      end
    end
  end
end