Sha256: 57e5a280a49c4a3a384e996fc99e6d11dfd3ae28bc50e7475adc4e69c3af1676
Contents?: true
Size: 987 Bytes
Versions: 1
Compression:
Stored size: 987 Bytes
Contents
require 'spec_helper' describe Morphine do let :Container do Class.new do include Morphine end end let(:container) { Container().new } describe 'register' do before do Container().register(:client) { 'client' } end it 'yields block to instantiate dependency' do container.client.should == 'client' end it 'memoizes result' do container.client.object_id.should == container.client.object_id end it 'instance evals block to resolve dependencies' do Container().register(:service) { Struct.new(:client).new(client) } container.service.client.should == container.client end it 'defines writer method to change service' do container.client = 'new client' container.client.should eq('new client') end it 'passes arguments through to the block' do Container().register(:pass_through) { |argument| argument } container.pass_through(:a).should == :a end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
morphine-0.1.1 | spec/morphine_spec.rb |