module ProcessSettings::Testing::Base::Helpers

Public Instance Methods

initial_instance() click to toggle source
# File lib/process_settings/testing/helpers.rb, line 37
def initial_instance
  @initial_instance ||= ProcessSettings.instance
end
stub_process_settings(settings_hash) click to toggle source

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.

@param [Hash] settings_hash

@return none

# 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