module I18n::Tests::Interpolation

Protected Instance Methods

capture(stream) { || ... } click to toggle source
# File lib/i18n/tests/interpolation.rb, line 138
def capture(stream)
  begin
    stream = stream.to_s
    eval "$#{stream} = StringIO.new"
    yield
    result = eval("$#{stream}").string
  ensure
    eval("$#{stream} = #{stream.upcase}")
  end

  result
end
euc_jp(string) click to toggle source
# File lib/i18n/tests/interpolation.rb, line 151
def euc_jp(string)
  string.encode!(Encoding::EUC_JP)
end
interpolate(*args) click to toggle source
# File lib/i18n/tests/interpolation.rb, line 155
def interpolate(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  key = args.pop
  I18n.backend.translate('en', key, options)
end