Sha256: af6231adbd922c9d805460fa1c895a29248e5d08a6e44a2c3afa0bdf06e2a76f
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
require 'spec_helper' describe 'Factory Method' do before :all do class TestService include SmartIoC::Iocify bean :test_service, package: :test inject :test_config attr_reader :test_config end class OtherService include SmartIoC::Iocify bean :other_service, package: :test inject :test_config attr_reader :test_config end class TestConfig include SmartIoC::Iocify bean :test_config, package: :test, factory_method: :build_config class Config end def build_config Config.new end end @test_service = SmartIoC.get_bean(:test_service) @other_service = SmartIoC.get_bean(:other_service) end it 'assigns bean with factory method' do expect(@test_service.test_config).to be_a(TestConfig::Config) end it 'assigns bean with factory method' do expect(@other_service.test_config).to be_a(TestConfig::Config) end context 'cross refference factory method beans' do before :all do class SingletonBean include SmartIoC::Iocify bean :singleton_bean, package: :cross_refference end class FactoryConfig include SmartIoC::Iocify bean :factory_config, factory_method: :build, package: :cross_refference inject :singleton_bean def build Object.new end end class FactoryLogger include SmartIoC::Iocify bean :factory_logger, factory_method: :build, package: :cross_refference inject :factory_config def build Object.new end end end it 'creates factory_logger bean' do expect(SmartIoC.get_bean(:factory_logger, package: :cross_refference)).to be_a(Object) end it 'creates factory_config bean' do expect(SmartIoC.get_bean(:factory_config, package: :cross_refference)).to be_a(Object) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart_ioc-0.1.28 | spec/smart_ioc/factory_method_spec.rb |