Sha256: 690a606c8db6aaed5d3806842e118fb830bff3de20355e92763e2e445a17a179

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

RSpec.describe Dry::Configurable::Config::Value do
  let(:klass) { Dry::Configurable::Config::Value }
  let(:config) { klass.new(name, value, processor) }
  let(:name) { :db }
  let(:value) { 'test' }
  let(:processor) { ->(v) { v } }

  describe '#initialize' do
    it 'coerces string name to symbol' do
      config = klass.new('db', value, processor)

      expect(config.name).to eq(:db)
    end
  end

  describe '#name' do
    subject! { config.name }

    it { is_expected.to eq(name) }
  end

  describe '#value' do
    subject! { config.value }

    context 'when value is not NONE' do
      it { is_expected.to eq(value) }
    end

    context 'when value is NONE' do
      let(:value) { klass::NONE }

      it { is_expected.to be(nil) }
    end
  end

  describe '#processor' do
    subject! { config.processor }

    it { is_expected.to eq(processor) }
  end

  describe '#none?' do
    subject! { config.none? }

    context 'when value is not NONE' do
      it { is_expected.to be(false) }
    end

    context 'when value is NONE' do
      let(:value) { klass::NONE }

      it { is_expected.to be(true) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-configurable-0.7.0 spec/unit/dry/configurable/config/value_spec.rb
dry-configurable-0.6.2 spec/unit/dry/configurable/config/value_spec.rb