-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add eager loading during finalization (#276)
* Add eager_loading as opton to Container#finalize! Default is false for now * Change eager_load: true by default * Inline conditional * Make spec file for eager loading --------- Co-authored-by: Nikita Shilnikov <[email protected]>
- Loading branch information
1 parent
3fbb624
commit 57b1e05
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
spec/integration/container/auto_registration/eager_loading_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters