Module: ProcessSettings::Testing::Base::Helpers

Included in:
Minitest::Helpers, RSpec::Helpers
Defined in:
lib/process_settings/testing/helpers.rb

Instance Method Summary collapse

Instance Method Details

#initial_instanceObject



37
38
39
# File 'lib/process_settings/testing/helpers.rb', line 37

def initial_instance
  @initial_instance ||= ProcessSettings.instance
end

#stub_process_settings(settings_hash) ⇒ Object

Adds the given settings_hash as an override at the end of the process_settings array, with default targeting (true). Therefore this will override these settings while leaving others alone.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/process_settings/testing/helpers.rb', line 19

def stub_process_settings(settings_hash)
  new_target_and_settings = ProcessSettings::TargetAndSettings.new(
    '<test_override>',
    Target::true_target,
    ProcessSettings::Settings.new(settings_hash.deep_stringify_keys)
  )

  new_process_settings = [
    *initial_instance.statically_targeted_settings,
    new_target_and_settings
  ]

  ProcessSettings.instance = ProcessSettings::Testing::Monitor.new(
    new_process_settings,
    logger: initial_instance.logger
  )
end