Sha256: fef5c02c9083f43b067870ee97116dce113a931485df7d6d4ac97d22b305f89f
Contents?: true
Size: 1.47 KB
Versions: 6
Compression:
Stored size: 1.47 KB
Contents
require 'spec_helper' describe SmartIoC do before :all do SmartIoC.clear dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/users') SmartIoC.find_package_beans(:users, dir_path) dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/admins') SmartIoC.find_package_beans(:admins, dir_path) dir_path = File.join(File.expand_path(File.dirname(__FILE__)), 'example/utils') SmartIoC.find_package_beans(:utils, dir_path) @container = SmartIoC::Container.get_instance end it 'sets beans' do users_creator = @container.get_bean(:users_creator) users_creator.create(1, 'test@test.com') repository = @container.get_bean(:repository, package: :admins) expect(repository.get(1)).to be_a(User) expect(users_creator.send(:repository)).to be_a(AdminsRepository) expect(users_creator.send(:logger)).to be_a(LoggerFactory::SmartIoCLogger) end it 'sets beans with extra package context' do SmartIoC::Container.get_instance.set_extra_context_for_package(:admins, :test) SmartIoC::Container.get_instance.force_clear_scopes users_creator = @container.get_bean(:users_creator) users_creator.create(1, 'test@test.com') repository = @container.get_bean(:repository, package: :admins) expect(users_creator.send(:repository)).to eq(TestAdminsRepository) expect(repository.get(1)).to be_a(User) expect(users_creator.send(:logger)).to be_a(LoggerFactory::SmartIoCLogger) end end
Version data entries
6 entries across 6 versions & 1 rubygems