Sha256: 3060177c3e111a2753427e4cba18149fc9f542743680e11fe3c625f31691e862
Contents?: true
Size: 862 Bytes
Versions: 1
Compression:
Stored size: 862 Bytes
Contents
# frozen_string_literal: true module Runger module Testing module Helpers # Sets the ENV variables to the provided # values and restore outside the block # # Also resets Runger.env before and after calling the block # to make sure that the values are not cached. # # NOTE: to remove the env value, pass `nil` as the value def with_env(data) was_values = [] data.each do |key, val| was_values << [key, ENV[key]] next ENV.delete(key) if val.nil? ENV[key] = val end # clear cached env values Runger.env.clear yield ensure was_values.each do |(key, val)| next ENV.delete(key) if val.nil? ENV[key] = val end # clear cache again Runger.env.clear end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
runger_config-4.0.0 | lib/runger/testing/helpers.rb |