Class: ErgomentumRspec::Helpers::EnvVarMockService
- Inherits:
-
Object
- Object
- ErgomentumRspec::Helpers::EnvVarMockService
- Defined in:
- lib/ergomentum_rspec/helpers/env_var_mock_service.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ EnvVarMockService
constructor
A new instance of EnvVarMockService.
- #mock_environment_variables(env_hash) ⇒ Object
- #restore_original_env_vars ⇒ Object
Constructor Details
#initialize ⇒ EnvVarMockService
Returns a new instance of EnvVarMockService.
10 11 12 |
# File 'lib/ergomentum_rspec/helpers/env_var_mock_service.rb', line 10 def initialize @original_env_values = {} end |
Class Method Details
.instance ⇒ Object
6 7 8 |
# File 'lib/ergomentum_rspec/helpers/env_var_mock_service.rb', line 6 def self.instance @instance ||= new end |
Instance Method Details
#mock_environment_variables(env_hash) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/ergomentum_rspec/helpers/env_var_mock_service.rb', line 14 def mock_environment_variables(env_hash) env_hash.each do |key, value| remember_original_env_value(key) ENV[key] = value end end |
#restore_original_env_vars ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ergomentum_rspec/helpers/env_var_mock_service.rb', line 21 def restore_original_env_vars @original_env_values.each do |key, value| ENV[key] = value end @original_env_values = {} end |