Sha256: dcdd2f321500e585c3ded1319251974c905371cb4c62b6f905abb90adfde1721
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
RSpec.describe Dry::Component::Injector do before do class Test::Container < Dry::Component::Container configure do |config| config.root = SPEC_ROOT.join("fixtures/test").realpath end load_paths! "lib" end end it "supports args injection by default" do obj = Class.new do include Test::Container::Inject["test.dep"] end.new expect(obj.dep).to be_a Test::Dep end it "supports args injection with explicit method" do obj = Class.new do include Test::Container::Inject.args["test.dep"] end.new expect(obj.dep).to be_a Test::Dep end it "supports hash injection" do obj = Class.new do include Test::Container::Inject.hash["test.dep"] end.new expect(obj.dep).to be_a Test::Dep end it "support kwargs injection" do obj = Class.new do include Test::Container::Inject.kwargs["test.dep"] end.new expect(obj.dep).to be_a Test::Dep end it "allows injection strategies to be swapped" do obj = Class.new do include Test::Container::Inject.kwargs.hash["test.dep"] end.new expect(obj.dep).to be_a Test::Dep end it "supports aliases" do obj = Class.new do include Test::Container::Inject[foo: "test.dep"] end.new expect(obj.foo).to be_a Test::Dep end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-component-0.3.0 | spec/unit/injector_spec.rb |
dry-component-0.2.0 | spec/unit/injector_spec.rb |
dry-component-0.1.0 | spec/unit/injector_spec.rb |