Sha256: 74db8d333c9758e630e22fd8b5bf59befb2656147268c79496ad6db4f8a586d4

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

require 'dry/system/container'

RSpec.describe Dry::System::Container, '.config' do
  subject(:config) { Test::Container.config }
  let(:configuration) { proc { } }

  before do
    class Test::Container < Dry::System::Container
    end
    Test::Container.configure(&configuration)
  end

  describe '#root' do
    subject(:root) { config.root }

    context 'no value' do
      it 'defaults to pwd' do
        expect(root).to eq Pathname.pwd
      end
    end

    context 'string provided' do
      let(:configuration) { proc { |config| config.root = '/tmp' } }

      it 'coerces string paths to pathname' do
        expect(root).to eq Pathname('/tmp')
      end
    end

    context 'pathname provided' do
      let(:configuration) { proc { |config| config.root = Pathname('/tmp') } }

      it 'accepts the pathname' do
        expect(root).to eq Pathname('/tmp')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-system-0.7.3 spec/unit/container/config_spec.rb
dry-system-0.7.2 spec/unit/container/config_spec.rb
dry-system-0.7.1 spec/unit/container/config_spec.rb