Sha256: c729f71cc7dfecb471599517cfc276d2de7f31afe1c7abaa7706df9b3f7e9715

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe ConfLoader do
  let(:path) { File.dirname(__FILE__) + '/../fixtures/simple.yml' }

  context 'conf loaded with production deployment setting' do

    let(:conf) { described_class.load(path, 'production') }

    it 'exposes production value' do
      expect(conf[:some_service]).to eq(host: 'some_service.production.com')
    end
  end

  context 'conf loaded with development deployment setting' do

    let(:conf) { described_class.load(path, 'development') }

    it 'exposes development value' do
      expect(conf[:some_service]).to eq(host: 'localhost')
    end
  end

  context 'with ENV variables declared' do

    let(:conf) { described_class.load(path, 'flexible') }

    before do
      ENV['FOO'] = 'foo-value'
    end

    it 'exposes ENV defined value' do
      expect(conf[:foo]).to eq('foo-value')
    end

    it 'exposes undefined ENV values as nil' do
      expect(conf[:undefined_val]).to be_nil
    end

    it 'exposes default value when ENV value not supplied' do
      expect(conf[:var_with_default_not_in_env]).to eq('default_value')
    end

    it 'skips default value when ENV value supplied' do
      expect(conf[:var_with_default_in_env]).to eq('foo-value')
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conf_loader-0.2.1 spec/integration/conf_loader_spec.rb