Sha256: b98753b56b7c495322aa0481ff08ebf65ef457d28ef3a2df0218bc873e5ac6d8

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

module MyApp; end

describe Configoro do
  subject { MyApp::Configuration }

  describe "#initialize" do
    it "should make the configuration available to MyApp::Configuration" do
      subject.should be_kind_of(Configoro::Hash)
    end

    it "should load data from the config files" do
      subject.basic.common_only.should eql('common')
    end

    it "should give priority to environment-specific files" do
      subject.basic.env_name.should eql('development')
    end

    it "should not load data from other environments" do
      subject.basic['should_not_exist'].should be_nil
    end

    it "should convert hashes recursively" do
      subject.hash_test.akey.should eql('value')
    end

    it "should deep-merge hashes" do
      subject.hash_test.subhash.key1.should eql('val1')
      subject.hash_test.subhash.key2.should eql('newval')
    end

    it "should not complain when there is no directory for the current environment" do
      Rails.stub!(:env).and_return('unknown')
      Configoro.initialize
      MyApp::Configuration.should eql({"basic"=>{"common_only"=>"common", "env_name"=>"common"}, "hash_test"=>{"akey"=>"value", "subhash"=>{"key1"=>"val1", "key2"=>"val2"}}})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
configoro-1.1.0 spec/configoro_spec.rb
configoro-1.0.0 spec/configoro_spec.rb