Sha256: b5b4ff3f4a6f77d7c7871f7cde77751736f00904d04cf1671918db1261a5d6eb
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
RSpec.describe 'Lazy-booting external deps' do before do module Test class Umbrella < Dry::System::Container configure do |config| config.name = :core config.root = SPEC_ROOT.join('fixtures/umbrella').realpath end end class App < Dry::System::Container configure do |config| config.name = :main end end end end shared_examples_for 'lazy booted dependency' do it 'lazy boots an external dep provided by top-level container' do expect(user_repo.repo).to be_instance_of(Db::Repo) end it 'loads an external dep during finalization' do system.finalize! expect(user_repo.repo).to be_instance_of(Db::Repo) end end context 'when top-level container provides the dependency' do let(:user_repo) do Class.new { include Test::Import['db.repo'] }.new end let(:system) { Test::Umbrella } before do module Test Umbrella.import(main: App) Import = Umbrella.injector end end it_behaves_like 'lazy booted dependency' end context 'when top-level container provides the dependency through import' do let(:user_repo) do Class.new { include Test::Import['core.db.repo'] }.new end let(:system) { Test::App } before do module Test App.import(core: Umbrella) Import = App.injector end end it_behaves_like 'lazy booted dependency' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-system-0.7.2 | spec/integration/import_spec.rb |
dry-system-0.7.1 | spec/integration/import_spec.rb |
dry-system-0.7.0 | spec/integration/import_spec.rb |