Class: RubyPitaya::SetupSpecHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rubypitaya-3.12.1/lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_setup = {}) ⇒ SetupSpecHelper

Returns a new instance of SetupSpecHelper.



5
6
7
8
9
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 5

def initialize(default_setup = {})
  @empty_hash = {}
  @setup_mock = {}
  @default_setup = default_setup
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 11

def [](key)
  split_key = key.split('.')
  result = @setup_mock.dig(*split_key)
  return result unless result.nil?

  @default_setup.dig(*split_key)
end

#add(key, value) ⇒ Object



26
27
28
29
30
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 26

def add(key, value)
  keys = key.split('.')
  add_hash = undig(*keys, value)
  @setup_mock = merge_recursively(@setup_mock, add_hash)
end

#auto_reloadObject



19
20
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 19

def auto_reload
end

#clearObject



39
40
41
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 39

def clear
  @setup_mock = {}
end

#fetch(*args) ⇒ Object



32
33
34
35
36
37
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 32

def fetch(*args)
  result = self[args[0]]
  return result unless result.nil?

  @empty_hash.fetch(*args)
end

#setup_mock=(value) ⇒ Object



22
23
24
# File 'lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb', line 22

def setup_mock=(value)
  @setup_mock = value
end