Sha256: 2f14b766d1df852b87d2e67eb8a598a0fa6b934cfbba7195cbd2a9bf6e693d29
Contents?: true
Size: 872 Bytes
Versions: 2
Compression:
Stored size: 872 Bytes
Contents
# encoding: utf-8 require 'i18n' module Layou2 module SubstitutionsHelper # Execute the block setting the given values and restoring old values after # the block is executed. def swap(object, new_values) old_values = {} new_values.each do |key, value| old_values[key] = object.send key object.send :"#{key}=", value end yield ensure old_values.each do |key, value| object.send :"#{key}=", value end end def store_translations(locale, translations, &block) current_translations = ::I18n.backend.send(:translations).send(:[], locale.to_sym) begin ::I18n.backend.store_translations locale, translations yield ensure # ::I18n.reload! end end end end ActiveSupport::TestCase.class_eval do include Layou2::SubstitutionsHelper end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
layou2-0.1.1 | test/support/substitutions_helper.rb |
layou2-0.1.0 | test/support/substitutions_helper.rb |