Sha256: 4ef5ba53369ae9eedf9385f7aaa23376497581ae8040c49227e6462a046d25ee
Contents?: true
Size: 1.52 KB
Versions: 4
Compression:
Stored size: 1.52 KB
Contents
require 'spec_helper' module Alf module Support describe Registry do let(:clazz){ Class.new.extend(Registry) } let(:seen) { [] } before do clazz.listen{|n,c| seen << [n,c] } end describe 'when used with classes' do before do clazz.register(Integer, clazz) end it 'installs class-level methods' do clazz.should respond_to(:integer) end it 'add the class to the registered elements' do clazz.registered.should eq([Integer]) clazz.all.should eq([Integer]) end it 'calls the listeners' do seen.should eq([[:integer, Integer]]) end end describe 'when used with an array and arguments' do before do clazz.register([:hello, Integer], clazz) end it 'installs class-level methods' do clazz.should respond_to(:hello) end it 'maintain the registered elements' do clazz.registered.should eq([[:hello, Integer]]) end it 'calls the listeners' do seen.should eq([[:hello, Integer]]) end end describe 'when listen after some components have already been registered' do before do clazz.register(Integer, clazz) end it 'calls the listener with registered components at listening time' do seen = [] clazz.listen{|n,c| seen << [n,c] } seen.should eq([[:integer, Integer]]) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems