Sha256: 4d243525f7ede8907d091ba441e4abe908883c8275ce10ca0bad7ceac336e954

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

RSpec::Matchers.define :be_a_subset_of do |default_locale_filepath|
  match do |filepath|
    locale_file = I18nSpec::LocaleFile.new(filepath)
    default_locale = I18nSpec::LocaleFile.new(default_locale_filepath)
    @superset = locale_file.flattened_translations.keys.reject do |key|
      default_locale.flattened_translations.keys.include?(key)
    end
    @superset.empty?
  end

  failure_meth = begin
                   method(:failure_message)
                 rescue NameError
                   method(:failure_message_for_should)
                 end

  failure_meth.call do |filepath|
    "expected #{filepath} to not include :\n- " << @superset.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/be_a_subset_of_matcher.rb
i18n-spec-0.5.0 lib/i18n-spec/matchers/be_a_subset_of_matcher.rb