Sha256: 27edfc02804c814ff13ef1a87aec59e92524a2600028fb1f834b84ec0e6970ad

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

describe 'Settings redefinition' do
  specify '.re_setting DSL command redefines previously defined setting keys' do
    class BaseRedefinableConfig < Qonfig::DataSet
      setting :nested do
        setting :some_key, 100_500
      end
    end

    class ChildRedefinitionConfig < BaseRedefinableConfig
      re_setting :nested, :some_value
    end

    class AnotherChildRedefinitionConfig < BaseRedefinableConfig
      re_setting :nested do
        setting :another_key, 'test'
      end
    end

    redefinable_config = BaseRedefinableConfig.new
    expect(redefinable_config[:nested][:some_key]).to eq(100_500)

    child_redefinition_config = ChildRedefinitionConfig.new
    expect(child_redefinition_config[:nested]).to eq(:some_value)

    another_child_redefinition_config = AnotherChildRedefinitionConfig.new
    expect(another_child_redefinition_config[:nested][:another_key]).to eq('test')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qonfig-0.28.0 spec/features/settings_redefinition_spec.rb
qonfig-0.27.0 spec/features/settings_redefinition_spec.rb
qonfig-0.26.0 spec/features/settings_redefinition_spec.rb