Sha256: 42322602ce2f1ab9d1591d58160c26f5e2948f96e4ad631102e07f37adb56028

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Armoire::Setting do
  let(:setting) do
    described_class.new({
      "simple" => "simple value",
      "nested" => {
        "config" => "nested config value"
      }
    })
  end

  describe '#[]' do
    context 'setting is a value' do
      subject { setting["simple"] }

      it 'returns the value' do
        expect(subject).to eql("simple value")
      end
    end

    context 'setting is a hash' do
      subject { setting["nested"] }

      it 'returns a new setting object' do
        expect(subject).to be_an_instance_of(described_class)
      end
    end

    context 'it can be chained' do
      subject { setting["nested"]["config"] }
      it 'returns the nested value' do
        expect(subject).to eql("nested config value")
      end
    end

    context 'missing key' do
      subject { setting["missing_setting"] }
      it "raises an error" do
        expect { subject }.to raise_error(Armoire::ConfigSettingMissing, '"missing_setting" is not set')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
armoire-1.4.1 spec/lib/armoire/setting_spec.rb
armoire-1.4.0 spec/lib/armoire/setting_spec.rb
armoire-1.3.0 spec/lib/armoire/setting_spec.rb
armoire-1.2.1 spec/lib/armoire/setting_spec.rb
armoire-1.1.0 spec/lib/armoire/setting_spec.rb
armoire-1.0.2 spec/lib/armoire/setting_spec.rb
armoire-1.0.1 spec/lib/armoire/setting_spec.rb