Sha256: ff87f037ae5794967252199292694e85045d0bc082622bc4c6e33662c10ea8bf

Contents?: true

Size: 685 Bytes

Versions: 29

Compression:

Stored size: 685 Bytes

Contents

module RubyPitaya

  class SetupSpecHelper

    def initialize
      @setup_mock = {}
    end

    def [](key)
      split_key = key.split('.')
      @setup_mock.dig(*split_key)
    end

    def auto_reload
    end

    def setup_mock=(value)
      @setup_mock = value
    end

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

    private

    def undig(*keys, value)
      keys.empty? ? value : { keys.first=>undig(*keys.drop(1), value) }
    end

    def merge_recursively(a, b)
      a.merge(b) {|key, a_item, b_item| merge_recursively(a_item, b_item) }
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
rubypitaya-3.0.1 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-3.0.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.27.1 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.27.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.26.3 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.26.2 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.26.1 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.26.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.25.1 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.25.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.24.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.23.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.22.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.21.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.20.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.19.1 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.19.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.18.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.17.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb
rubypitaya-2.16.0 ./lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb