Sha256: 9dfe84790e5266a77edb48fbfc31b8de54844b70eb3b0074ba2a0da928374439
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Syringe::Container do context 'when instantiated' do subject do Syringe::Container.new end it 'should allow register and retrieve objects that can to be injected' do subject.register(:some_string) { |container| 'Some string' } subject[:some_string].should == 'Some string' subject.some_string.should == 'Some string' subject.register(:some_number) { |container| 1212 } subject[:some_number].should == 1212 subject.some_number.should == 1212 end it 'should raise error if a object already is registered' do subject.register(:some_string) { |container| 'Some string' } subject[:some_string].should == 'Some string' lambda { subject.register(:some_string) { |container| 'Some string' } }.should raise_error Syringe::DuplicateServiceError end it 'should raise error if a object was not registered' do lambda { subject[:some_string] }.should raise_error Syringe::MissingServiceError end end context 'when used as default container instance' do context 'and configured with registered objects' do it 'should be able to do dependency injection on classes' do default_container = Syringe::Container.default default_container.register(:service_uri) { |container| 'http://services.syringe.org/api' } service_consumer = SyringeHelperClasses::ServiceConsumer.new service_consumer.respond_to?(:service_uri).should == true service_consumer.service_uri.should == 'http://services.syringe.org/api' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
syringe-0.0.1.pre | spec/syringe_spec.rb |