Sha256: 48ed663abde0796fdf02e4b15c3d6d851f92f8396045123ffafcd47873d796cd
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require 'ostruct' describe ProtocolRegistry do before(:each) do @backup_all = ProtocolRegistry.protocols.dup @backup_map = ProtocolRegistry.class_protocols.dup ProtocolRegistry.protocols = [] ProtocolRegistry.class_protocols = {} end after(:each) do ProtocolRegistry.protocols = @backup_all ProtocolRegistry.class_protocols = @backup_map end context '#add_protocol' do it 'adds a protocol to the main protocol list' do x = Object.new ProtocolRegistry.add_protocol x ProtocolRegistry.protocols.should include(x) end end context '#add_class_protocol' do it 'adds a protocol to the main protocol list, and adds a shortcut in the class map' do x = OpenStruct.new x.class_used = OpenStruct.new x.class_used.path = 'SuperPath' ProtocolRegistry.add_class_protocol x ProtocolRegistry.protocols.should include(x) ProtocolRegistry.class_protocols['SuperPath'].should == x end end context '#[]' do it 'looks up quick queries by class path' do x = OpenStruct.new x.class_used = OpenStruct.new x.class_used.path = 'SuperPath' ProtocolRegistry.add_class_protocol x ProtocolRegistry['SuperPath'].should == [x] end end context '#query' do context 'with :class_path specified' do it 'finds the classes in the registry with the given path' do x = OpenStruct.new x.class_used = OpenStruct.new x.class_used.path = 'SuperPath' ProtocolRegistry.add_class_protocol x ProtocolRegistry.query(:class_path => 'SuperPath').should == [x] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wool-0.5.1 | spec/analysis_specs/protocol_registry_spec.rb |