Sha256: 7d18a007e8f3f500f248dfcf28f140d014207db193cde7b1ec776357e3a779e4
Contents?: true
Size: 743 Bytes
Versions: 3
Compression:
Stored size: 743 Bytes
Contents
# frozen_string_literal: true module Runger::Testing::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.fetch(key, nil)] 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
runger_config-5.2.0 | lib/runger/testing/helpers.rb |
runger_config-5.1.0 | lib/runger/testing/helpers.rb |
runger_config-5.0.0 | lib/runger/testing/helpers.rb |