You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/spec/support/env_helpers.rb

24 lines
464 B

# frozen_string_literal: true
# Tiny helper to set ENV vars for the duration of a block, then restore.
module EnvHelpers
def with_env(vars)
original = {}
vars.each do |k, v|
original[k] = ENV.fetch(k, nil)
if v.nil?
ENV.delete(k)
else
ENV[k] = v
end
end
yield
ensure
original.each { |k, v| v.nil? ? ENV.delete(k) : ENV[k] = v }
end
end
RSpec.configure do |config|
config.include EnvHelpers
end