Sha256: a6c87b6c4a4f6ea48d43fcdd759126bb47877036e219396928ea495594013aa1

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

describe 'Get config values' do
  subject(:config) do
    Qonfig::DataSet.build do
      setting :some_nested_setting do
        setting :username, 'your_cool_name_here'
        setting :password, 'secure_password'
      end

      setting :role, 'cool guy'
    end.settings
  end

  describe '#[]' do
    it 'properly gets value by value' do
      expect(config[:some_nested_setting][:username]).to eq('your_cool_name_here')
      expect(config[:some_nested_setting][:password]).to eq('secure_password')
      expect(config[:role]).to eq('cool guy')
    end

    context 'with key path' do
      it 'properly gets value' do
        expect(config[:some_nested_setting, :username]).to eq('your_cool_name_here')
        expect(config[:some_nested_setting, :password]).to eq('secure_password')
      end
    end

    context "when setting doesn't exist" do
      it 'raises error' do
        expect { config[:some_nested_setting, :kek] }.to raise_error(Qonfig::UnknownSettingError)
      end
    end

    context 'when zero arguments passed' do
      it 'raises error' do
        expect { config[] }.to raise_error(Qonfig::ArgumentError)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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