Skip to content

Commit

Permalink
Make spec file for eager loading
Browse files Browse the repository at this point in the history
  • Loading branch information
cllns committed Jul 2, 2024
1 parent f631297 commit 57cf692
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions spec/integration/container/auto_registration/eager_loading_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

RSpec.describe "Eager loading during finalization" do
it "raises error when component cannot be found, due to missing inflection" do
class Test::Container < Dry::System::Container
configure do |config|
config.root = SPEC_ROOT.join("fixtures").realpath

config.component_dirs.add "components" do |dir|
dir.namespaces.add "test", key: nil
end
end
end
expect { Test::Container.finalize! }.to raise_error(Dry::System::ComponentNotLoadableError)
end

it "does not raise error when constant can be found" do
class Test::Container < Dry::System::Container
configure do |config|
config.root = SPEC_ROOT.join("fixtures").realpath

config.component_dirs.add "components" do |dir|
dir.namespaces.add "test", key: nil
end

config.inflector = Dry::Inflector.new { |i| i.acronym("ABC") }
end
end
expect { Test::Container.finalize! }.to_not raise_error
end
end
4 changes: 3 additions & 1 deletion spec/integration/container/auto_registration/memoize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Test::Container < Dry::System::Container
!component.key.match?(/bar/)
end
end

config.inflector = Dry::Inflector.new { |i| i.acronym("ABC") }
end
end
end
Expand All @@ -68,7 +70,7 @@ class Test::Container < Dry::System::Container

context "Finalized container" do
before do
Test::Container.finalize!(eager_load: false)
Test::Container.finalize!
end

include_examples "memoizing components"
Expand Down

0 comments on commit 57cf692

Please sign in to comment.