Sha256: 72ef5c7da663a5282a49906d7f3612f479da5f1513d8aaa41141477a1dcf7475

Contents?: true

Size: 741 Bytes

Versions: 2

Compression:

Stored size: 741 Bytes

Contents

RSpec::Matchers.define :have_missing_pluralization_keys do
  match do |actual|
    @locale_file = I18nSpec::LocaleFile.new(actual)
    @locale_file.missing_pluralization_keys.any?
  end

  failure_meth = begin
                   method(:failure_message_when_negated)
                 rescue NameError
                   method(:failure_message_for_should_not)
                 end

  failure_meth.call do |filepath|
    flattened_keys = []

    @locale_file.errors[:missing_pluralization_keys].each do |parent, subkeys|
      subkeys.each do |subkey|
        flattened_keys << [parent, subkey].join('.')
      end
    end

    "expected #{filepath} to contain the following pluralization keys :\n- " << flattened_keys.join("\n- ")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n-spec-0.5.1 lib/i18n-spec/matchers/have_missing_pluralization_keys_matcher.rb
i18n-spec-0.5.0 lib/i18n-spec/matchers/have_missing_pluralization_keys_matcher.rb