Sha256: b8bb1e31ffe8b6d543279ac03db164189fd48bc898947728cd86c88c3ecd0f34

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'

describe Confrider::Core do
  let(:cfg) { Confrider::Core.new :foo => 'bar' }

  context '#initialize' do
    it 'should init @vault' do
      cfg.instance_variable_get('@vault').should be
    end
  end

  context '#save_hash' do
    let(:cfg) { Confrider::Core.new 'foo' => {'bar' => {'baz' => 'value'}} }

    it 'should flatten hash keys' do
      cfg['foo.bar.baz'].should == 'value'
    end
  end

  context '#[]' do
    it 'should return value' do
      cfg['foo'].should == 'bar'
    end

    it 'should return default value if nothing found' do
      cfg['foo2', 'default value'].should == 'default value'
    end
  end

  context '#normalize_keys' do
    it 'should join keys with "."' do
      cfg.normalize_keys('q', 'a', 'z').should == 'q.a.z'
    end

    it 'should remove leading "."' do
      cfg.normalize_keys(nil, 'q').should == 'q'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
confrider-0.0.1 spec/lib/confrider/core_spec.rb