Module: Scarpe::Test::Helpers

Includes:
Components::FileHelpers, Components::ProcessHelpers
Included in:
CCInstance
Defined in:
scarpe-components/lib/scarpe/components/unit_test_helpers.rb

Overview

General helpers for general usage. Helpers here should not use Webview-specific functionality. The intention is that these are helpers for various Scarpe display services that do not necessarily use Webview.

Instance Method Summary collapse

Methods included from Components::ProcessHelpers

#run_out_err_result

Methods included from Components::FileHelpers

#with_tempfile, #with_tempfiles

Instance Method Details

#with_env_vars(envs) ⇒ Object

Temporarily set env vars for the block of code inside. The old environment variable values will be restored after the block finishes.



30
31
32
33
34
35
36
37
38
39
# File 'scarpe-components/lib/scarpe/components/unit_test_helpers.rb', line 30

def with_env_vars(envs)
  old_env = {}
  envs.each do |k, v|
    old_env[k] = ENV[k]
    ENV[k] = v
  end
  yield
ensure
  old_env.each { |k, v| ENV[k] = v }
end