jackbox 0.9.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/CHANGES.txt +108 -0
- data/LICENSE.lic +0 -0
- data/LICENSE.txt +13 -0
- data/README.md +1395 -0
- data/Rakefile +6 -0
- data/bin/jackup +248 -0
- data/jackbox.gemspec +27 -0
- data/jackbox.jpg +0 -0
- data/lib/.document +0 -0
- data/lib/jackbox.rb +2 -0
- data/lib/jackbox/examples/dir.rb +80 -0
- data/lib/jackbox/examples/dx.rb +182 -0
- data/lib/jackbox/examples/transformers.rb +101 -0
- data/lib/jackbox/injectors.rb +2 -0
- data/lib/jackbox/rake.rb +2 -0
- data/lib/jackbox/tools/prefs.rb +2 -0
- data/lib/jackbox/version.rb +4 -0
- data/rgloader/loader.rb +23 -0
- data/rgloader/rgloader.darwin.bundle +0 -0
- data/rgloader/rgloader.freebsd.so +0 -0
- data/rgloader/rgloader.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader.linux.so +0 -0
- data/rgloader/rgloader.linux.x86_64.so +0 -0
- data/rgloader/rgloader.mingw.so +0 -0
- data/rgloader/rgloader19.darwin.bundle +0 -0
- data/rgloader/rgloader19.freebsd.so +0 -0
- data/rgloader/rgloader19.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader19.linux.so +0 -0
- data/rgloader/rgloader19.linux.x86_64.so +0 -0
- data/rgloader/rgloader19.mingw.so +0 -0
- data/rgloader/rgloader191.mingw.so +0 -0
- data/rgloader/rgloader192.darwin.bundle +0 -0
- data/rgloader/rgloader192.freebsd.so +0 -0
- data/rgloader/rgloader192.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader192.linux.so +0 -0
- data/rgloader/rgloader192.linux.x86_64.so +0 -0
- data/rgloader/rgloader192.mingw.so +0 -0
- data/rgloader/rgloader193.darwin.bundle +0 -0
- data/rgloader/rgloader193.freebsd.so +0 -0
- data/rgloader/rgloader193.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader193.linux.so +0 -0
- data/rgloader/rgloader193.linux.x86_64.so +0 -0
- data/rgloader/rgloader193.mingw.so +0 -0
- data/rgloader/rgloader20.darwin.bundle +0 -0
- data/rgloader/rgloader20.freebsd.so +0 -0
- data/rgloader/rgloader20.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader20.linux.so +0 -0
- data/rgloader/rgloader20.linux.x86_64.so +0 -0
- data/rgloader/rgloader20.mingw.so +0 -0
- data/rgloader/rgloader20.mingw.x64.so +0 -0
- data/rgloader/rgloader21.darwin.bundle +0 -0
- data/rgloader/rgloader21.freebsd.so +0 -0
- data/rgloader/rgloader21.freebsd.x86_64.so +0 -0
- data/rgloader/rgloader21.linux.so +0 -0
- data/rgloader/rgloader21.linux.x86_64.so +0 -0
- data/rgloader/rgloader21.mingw.so +0 -0
- data/rgloader/rgloader21.mingw.x64.so +0 -0
- data/rgloader/rgloader22.darwin.bundle +0 -0
- data/rgloader/rgloader22.freebsd.so +0 -0
- data/rgloader/rgloader22.linux.so +0 -0
- data/rgloader/rgloader22.linux.x86_64.so +0 -0
- data/rgloader/rgloader22.mingw.so +0 -0
- data/rgloader/rgloader22.mingw.x64.so +0 -0
- data/spec/bin/jackup_cmd_shared.rb +176 -0
- data/spec/bin/jackup_cmd_spec.rb +292 -0
- data/spec/lib/abtract_spec.rb +56 -0
- data/spec/lib/jackbox/examples/dir_spec.rb +112 -0
- data/spec/lib/jackbox/examples/dx_spec.rb +346 -0
- data/spec/lib/jackbox/examples/result.xml +15 -0
- data/spec/lib/jackbox/examples/source1.xml +11 -0
- data/spec/lib/jackbox/examples/source2.xml +15 -0
- data/spec/lib/jackbox/examples/source3.xml +11 -0
- data/spec/lib/jackbox/examples/trasnformers_spec.rb +35 -0
- data/spec/lib/jackbox/injector_composition_spec.rb +950 -0
- data/spec/lib/jackbox/injector_directives_spec.rb +266 -0
- data/spec/lib/jackbox/injector_inheritance_spec.rb +799 -0
- data/spec/lib/jackbox/injector_introspection_spec.rb +614 -0
- data/spec/lib/jackbox/injector_namespacing_spec.rb +345 -0
- data/spec/lib/jackbox/injector_spec.rb +847 -0
- data/spec/lib/jackbox/injector_versioning_spec.rb +334 -0
- data/spec/lib/jackbox/patterns_spec.rb +410 -0
- data/spec/lib/jackbox/prefs_spec.rb +212 -0
- data/spec/lib/jackbox/reclassing_spec.rb +394 -0
- data/spec/lib/jackbox_spec.rb +595 -0
- data/spec/spec_helper.rb +139 -0
- metadata +218 -0
| @@ -0,0 +1,614 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            include Injectors
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            describe "the introspection api in further detail" do
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            	describe :injectors do
         | 
| 9 | 
            +
            		
         | 
| 10 | 
            +
            	  # . Name.injectors == [j,......]
         | 
| 11 | 
            +
            	  # . Name.injectors.by_name == [:name, ......]
         | 
| 12 | 
            +
            	  # . Name.injectors.sym_list == [:name, ......]
         | 
| 13 | 
            +
            	  # . Name.injectors.collect_by_name(:name) == [j,......]  (default method)
         | 
| 14 | 
            +
            	  #   . same as Name.injectors :name
         | 
| 15 | 
            +
            	  # . Name.injectors.all_by_sym(:name) == [j,......]  (default method)
         | 
| 16 | 
            +
            	  # . Name.injectors.find_by_name(:name) == j
         | 
| 17 | 
            +
            	  # . Name.injectors.#Enumerable...
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
            		describe "base injectors call" do
         | 
| 20 | 
            +
            			
         | 
| 21 | 
            +
            			before do
         | 
| 22 | 
            +
            				class InjectorContainer
         | 
| 23 | 
            +
            					injector :function
         | 
| 24 | 
            +
            					injector :style
         | 
| 25 | 
            +
            			
         | 
| 26 | 
            +
            					inject function, style
         | 
| 27 | 
            +
            				end
         | 
| 28 | 
            +
            			end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            			the 'base call returns now a list of actual injector objects' do
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            			  # . Name.injectors == [j,......]
         | 
| 33 | 
            +
            		
         | 
| 34 | 
            +
            				# class InjectorContainer
         | 
| 35 | 
            +
            				# 	injector :function
         | 
| 36 | 
            +
            				# 	injector :style
         | 
| 37 | 
            +
            				# 	
         | 
| 38 | 
            +
            				# 	inject function, style
         | 
| 39 | 
            +
            				# end
         | 
| 40 | 
            +
            		
         | 
| 41 | 
            +
            				expect(InjectorContainer.injectors).to all( be_an(Injector))                       
         | 
| 42 | 
            +
            				expect(InjectorContainer.injectors).to eql([InjectorContainer.function.history.last, InjectorContainer.style.history.last])
         | 
| 43 | 
            +
            		
         | 
| 44 | 
            +
            			end
         | 
| 45 | 
            +
            	
         | 
| 46 | 
            +
            			the 'injectors#by_name alias sym_list call now returns the list of injector symbols' do
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            			  # . Name.injectors.by_name == [:name, ......]
         | 
| 49 | 
            +
            		
         | 
| 50 | 
            +
            				# class InjectorContainer
         | 
| 51 | 
            +
            				# 	injector :function
         | 
| 52 | 
            +
            				# 	injector :style
         | 
| 53 | 
            +
            				# 
         | 
| 54 | 
            +
            				# 	inject function, style
         | 
| 55 | 
            +
            				# end
         | 
| 56 | 
            +
            	
         | 
| 57 | 
            +
            				expect(InjectorContainer.injectors.by_name).to all( be_an(Symbol))
         | 
| 58 | 
            +
            				expect(InjectorContainer.injectors.by_name).to eql([:function, :style])
         | 
| 59 | 
            +
            				# alias
         | 
| 60 | 
            +
            				expect(InjectorContainer.injectors.sym_list).to all( be_an(Symbol))
         | 
| 61 | 
            +
            		
         | 
| 62 | 
            +
            			end
         | 
| 63 | 
            +
            	
         | 
| 64 | 
            +
            			the 'injectors.collect_by_name returns a list of injector objects matching the name' do
         | 
| 65 | 
            +
            	
         | 
| 66 | 
            +
            				# class InjectorContainer
         | 
| 67 | 
            +
            				# 	injector :function
         | 
| 68 | 
            +
            				# 	injector :style
         | 
| 69 | 
            +
            				# 
         | 
| 70 | 
            +
            				# 	inject function, style
         | 
| 71 | 
            +
            				# end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            				ic = InjectorContainer.new
         | 
| 74 | 
            +
            				ic.enrich InjectorContainer.style
         | 
| 75 | 
            +
            				ic.injectors.by_name.should == [:function, :style, :style]
         | 
| 76 | 
            +
            		
         | 
| 77 | 
            +
            				# returns [Injector.name == :style, Injector.name == :style] only !!
         | 
| 78 | 
            +
            				ic.injectors.collect_by_name(:style).should all(be_an(Injector).and have_attributes(:name => :style))
         | 
| 79 | 
            +
            		
         | 
| 80 | 
            +
            				# also aliased
         | 
| 81 | 
            +
            				ic.injectors.all_by_sym(:style).should all(be_an(Injector).and have_attributes(:name => :style))
         | 
| 82 | 
            +
            			end
         | 
| 83 | 
            +
            	
         | 
| 84 | 
            +
            			the 'injectors.find_by_name call returns one item of class Injector by name <sym>' do
         | 
| 85 | 
            +
            		
         | 
| 86 | 
            +
            				# class InjectorContainer
         | 
| 87 | 
            +
            				# 	injector :function
         | 
| 88 | 
            +
            				# 	injector :style
         | 
| 89 | 
            +
            				# 
         | 
| 90 | 
            +
            				# 	inject function, style
         | 
| 91 | 
            +
            				# end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            				ic = InjectorContainer.new
         | 
| 94 | 
            +
            				ic.enrich InjectorContainer.style
         | 
| 95 | 
            +
            	
         | 
| 96 | 
            +
            				# result
         | 
| 97 | 
            +
            				ic.injectors.by_name.should == [:function, :style, :style]
         | 
| 98 | 
            +
            				ic.injectors.find_by_name(:style).should be_an(Injector).and( have_attributes(:name => :style))  # the last one !!!
         | 
| 99 | 
            +
            		
         | 
| 100 | 
            +
            				# also aliased
         | 
| 101 | 
            +
            				ic.injectors.last_by_sym(:style).should be_an(Injector).and( have_attributes(:name => :style))  # the last one !!!
         | 
| 102 | 
            +
            		
         | 
| 103 | 
            +
            			end
         | 
| 104 | 
            +
            	
         | 
| 105 | 
            +
            			the 'default calls injectors :name/injectors :name, :othername, ... get resolved to the previous methods' do
         | 
| 106 | 
            +
            		
         | 
| 107 | 
            +
            				# class InjectorContainer
         | 
| 108 | 
            +
            				# 	injector :function
         | 
| 109 | 
            +
            				# 	injector :style
         | 
| 110 | 
            +
            				# 
         | 
| 111 | 
            +
            				# 	inject function, style
         | 
| 112 | 
            +
            				# end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            				ic = InjectorContainer.new
         | 
| 115 | 
            +
            				ic.enrich InjectorContainer.style
         | 
| 116 | 
            +
            	
         | 
| 117 | 
            +
            				# result
         | 
| 118 | 
            +
            				ic.injectors(:style).should eql(InjectorContainer.style.history.last)
         | 
| 119 | 
            +
            				ic.injectors(:style, :style).should all(be_an(Injector).and have_attributes(:name => :style))
         | 
| 120 | 
            +
            	
         | 
| 121 | 
            +
            			end
         | 
| 122 | 
            +
            		
         | 
| 123 | 
            +
            		end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            		describe '#injectors at the class singleton level' do
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            			the 'injectors applied at the class INSTANCE level show only on the class not the object instances' do
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            				injector :class_injector do
         | 
| 130 | 
            +
            					def new *args
         | 
| 131 | 
            +
            						puts "--done--"
         | 
| 132 | 
            +
            						super(*args)
         | 
| 133 | 
            +
            					end
         | 
| 134 | 
            +
            				end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
            				class InjectorUser
         | 
| 137 | 
            +
            					# ...
         | 
| 138 | 
            +
            				end
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            				InjectorUser.extend class_injector
         | 
| 141 | 
            +
             | 
| 142 | 
            +
            				$stdout.should_receive(:puts).with("--done--")
         | 
| 143 | 
            +
            				iu = InjectorUser.new
         | 
| 144 | 
            +
             | 
| 145 | 
            +
            				InjectorUser.injectors.size.should == 1
         | 
| 146 | 
            +
            				InjectorUser.injectors.should all(be_an(Injector).and have_attributes(:name => :class_injector))
         | 
| 147 | 
            +
             | 
| 148 | 
            +
            				if iu.respond_to? :injectors								# done to run this file independent of the others
         | 
| 149 | 
            +
            					iu.injectors.should be_empty
         | 
| 150 | 
            +
            				else
         | 
| 151 | 
            +
            					expect{
         | 
| 152 | 
            +
            						iu.injectors
         | 
| 153 | 
            +
            					}.to raise_error(NoMethodError)
         | 
| 154 | 
            +
            				end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
            			end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
            			the 'injector list for classes lists CLASS instance injectors first then OBJECT instance injectors' do
         | 
| 159 | 
            +
             | 
| 160 | 
            +
            				injector :two
         | 
| 161 | 
            +
            				injector :one
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            				Array.inject two 														# injected on objects of the class
         | 
| 164 | 
            +
            				Array.extend one														# extended on the class instance itself
         | 
| 165 | 
            +
             | 
| 166 | 
            +
            				# result
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            				Array.injectors.sym_list.should == [:one, :two]
         | 
| 169 | 
            +
             | 
| 170 | 
            +
            			end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            		end
         | 
| 173 | 
            +
             | 
| 174 | 
            +
            		describe "#injectors(:all) call" do
         | 
| 175 | 
            +
             | 
| 176 | 
            +
            			injector :Example1
         | 
| 177 | 
            +
            			injector :Example2
         | 
| 178 | 
            +
             | 
| 179 | 
            +
            			it 'returns all the injectors in the ancestor chain of an object' do
         | 
| 180 | 
            +
             | 
| 181 | 
            +
            				Object.eject *Object.injectors rescue []  # clear all injectors from other tests
         | 
| 182 | 
            +
             | 
| 183 | 
            +
            				Object.inject Example1()
         | 
| 184 | 
            +
            				Hash.inject Example2()
         | 
| 185 | 
            +
             | 
| 186 | 
            +
            				Hash.new.injectors(:all).should all(be_an(Injector))
         | 
| 187 | 
            +
            				Hash.new.injectors(:all).map(&:spec).should eql [Example2(), Example1()]
         | 
| 188 | 
            +
             | 
| 189 | 
            +
            				# as opposed to simple #injectors call
         | 
| 190 | 
            +
            				Hash.new.injectors.map(&:spec).should eql [Example2()]
         | 
| 191 | 
            +
             | 
| 192 | 
            +
            			end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
            			it 'returns all the injectors in the ancestors chain of a class' do
         | 
| 195 | 
            +
             | 
| 196 | 
            +
            				# Object.eject *Object.injectors          	# clear all injectors from other tests
         | 
| 197 | 
            +
             | 
| 198 | 
            +
            				class Aclass
         | 
| 199 | 
            +
            					inject Example2()
         | 
| 200 | 
            +
            				end
         | 
| 201 | 
            +
             | 
| 202 | 
            +
            				Aclass.injectors(:all).should all(be_an(Injector))
         | 
| 203 | 
            +
            				Aclass.injectors(:all).map(&:spec).should eql [Example2(), Example1()]
         | 
| 204 | 
            +
             | 
| 205 | 
            +
            				# as opposed to simple #injectors call
         | 
| 206 | 
            +
            				Aclass.new.injectors.map(&:spec).should eql [Example2()]
         | 
| 207 | 
            +
             | 
| 208 | 
            +
            			end
         | 
| 209 | 
            +
             | 
| 210 | 
            +
            			it 'returns all the injectors in the ancestors chain of a module' do
         | 
| 211 | 
            +
             | 
| 212 | 
            +
            				module Amodule
         | 
| 213 | 
            +
            					inject Example2() do
         | 
| 214 | 
            +
            						include injector :Gone
         | 
| 215 | 
            +
            					end
         | 
| 216 | 
            +
            				end
         | 
| 217 | 
            +
             | 
| 218 | 
            +
            				Amodule.injectors(:all).should all(be_an(Injector))
         | 
| 219 | 
            +
            				Amodule.injectors(:all).map(&:spec).should eql [Example2(), Gone()]
         | 
| 220 | 
            +
             | 
| 221 | 
            +
            				# as opposed to simple #injectors call
         | 
| 222 | 
            +
            				Amodule.injectors.map(&:spec).should eql [Example2()]
         | 
| 223 | 
            +
             | 
| 224 | 
            +
            			end
         | 
| 225 | 
            +
             | 
| 226 | 
            +
            			it 'returns all the injectors in the ancestors chain of a Injector' do
         | 
| 227 | 
            +
             | 
| 228 | 
            +
            				injector :Example1 do
         | 
| 229 | 
            +
            					include injector :Example2 do
         | 
| 230 | 
            +
            						include injector :Gone
         | 
| 231 | 
            +
            					end
         | 
| 232 | 
            +
            				end
         | 
| 233 | 
            +
             | 
| 234 | 
            +
            				Example1().injectors(:all).should all(be_an(Injector)) 
         | 
| 235 | 
            +
            				Example1().injectors(:all).map(&:spec).should eql [Example1(), Example2(), Gone()]
         | 
| 236 | 
            +
             | 
| 237 | 
            +
            				# as opposed to simple #injectors call
         | 
| 238 | 
            +
            				Example1().injectors.map(&:spec).should eql [Example2()]
         | 
| 239 | 
            +
             | 
| 240 | 
            +
            			end
         | 
| 241 | 
            +
             | 
| 242 | 
            +
            			it 'allows the rest of the api on the entire list' do
         | 
| 243 | 
            +
             | 
| 244 | 
            +
            				Example1().injectors(:all).by_name.should == [:Example1, :Example2, :Gone] 
         | 
| 245 | 
            +
            				Example1().injectors(:all).collect_by_name(:Gone).should all(be_an(Injector).and have_attributes(:name => :Gone))
         | 
| 246 | 
            +
            				Example1().injectors(:all).find_by_name(:Example2).name.should == :Example2
         | 
| 247 | 
            +
             | 
| 248 | 
            +
            			end
         | 
| 249 | 
            +
            		end
         | 
| 250 | 
            +
             | 
| 251 | 
            +
            	end
         | 
| 252 | 
            +
             | 
| 253 | 
            +
            	describe :history do
         | 
| 254 | 
            +
             | 
| 255 | 
            +
            		jack :Histample                  
         | 
| 256 | 
            +
             | 
| 257 | 
            +
            		it 'does not show original jack' do 
         | 
| 258 | 
            +
            			expect(Histample().history.first).to eq(nil)
         | 
| 259 | 
            +
            		end 
         | 
| 260 | 
            +
            		
         | 
| 261 | 
            +
            		it "shows additional jacks after extended/included" do
         | 
| 262 | 
            +
            			
         | 
| 263 | 
            +
            			extend(Histample(), Histample())
         | 
| 264 | 
            +
            			
         | 
| 265 | 
            +
            			injectors.should == Histample().history
         | 
| 266 | 
            +
             | 
| 267 | 
            +
            			expect(Histample().history.size).to eq(2)
         | 
| 268 | 
            +
            			expect(Histample().history.last).to eql(Histample())
         | 
| 269 | 
            +
            			expect(Histample().history.last).to_not eq(Histample().spec)
         | 
| 270 | 
            +
            			
         | 
| 271 | 
            +
            			eject *injectors
         | 
| 272 | 
            +
            			
         | 
| 273 | 
            +
            		end
         | 
| 274 | 
            +
            		
         | 
| 275 | 
            +
            		it "allows you to retreive items using an index" do
         | 
| 276 | 
            +
            			
         | 
| 277 | 
            +
            			extend Histample(), Histample()
         | 
| 278 | 
            +
            			
         | 
| 279 | 
            +
            			injectors.should == Histample().history
         | 
| 280 | 
            +
             | 
| 281 | 
            +
            			expect(Histample().history.slice(0)).to be_instance_of(Injector)
         | 
| 282 | 
            +
            			expect(Histample().history.slice(1)).to be_instance_of(Injector) 
         | 
| 283 | 
            +
            			expect(Histample().history.slice(0)).to eq(Histample())
         | 
| 284 | 
            +
            			expect(Histample().history.slice(1)).to eq(Histample()) 
         | 
| 285 | 
            +
            			
         | 
| 286 | 
            +
            			# values are different than spec
         | 
| 287 | 
            +
            			
         | 
| 288 | 
            +
            			expect(Histample().history.slice(0)).not_to eq(Histample().spec)
         | 
| 289 | 
            +
            			expect(Histample().history.slice(1)).not_to eq(Histample().spec) 
         | 
| 290 | 
            +
            			
         | 
| 291 | 
            +
            			eject Histample(), Histample()
         | 
| 292 | 
            +
            			
         | 
| 293 | 
            +
            		end
         | 
| 294 | 
            +
            		
         | 
| 295 | 
            +
            		it 'swallows items once ejected' do
         | 
| 296 | 
            +
            			
         | 
| 297 | 
            +
            			extend(Histample(), Histample())
         | 
| 298 | 
            +
            			
         | 
| 299 | 
            +
            			expect(Histample().history.size).to eq(2)
         | 
| 300 | 
            +
            			expect(Histample().history.last).to eql(Histample())
         | 
| 301 | 
            +
            			expect(Histample().history.last).to_not eq(Histample().spec)
         | 
| 302 | 
            +
            			
         | 
| 303 | 
            +
            			eject *injectors
         | 
| 304 | 
            +
            			
         | 
| 305 | 
            +
            			expect(injectors).to be_empty  							# target injectors
         | 
| 306 | 
            +
            			
         | 
| 307 | 
            +
            			expect(Histample().history.size).to eq(0)    # Injector history
         | 
| 308 | 
            +
            			expect(Histample().history.first).to eq(nil)
         | 
| 309 | 
            +
            			expect(Histample().history.last).to eq(nil)
         | 
| 310 | 
            +
            			
         | 
| 311 | 
            +
            		end
         | 
| 312 | 
            +
            		
         | 
| 313 | 
            +
            		it 'swallows un-hosted elements other than original' do
         | 
| 314 | 
            +
            			
         | 
| 315 | 
            +
            			Histample() #un-hosted Histample 
         | 
| 316 | 
            +
            			Histample() #un-hosted Histample
         | 
| 317 | 
            +
            			
         | 
| 318 | 
            +
            			expect(Histample().history.first).to eq(nil)
         | 
| 319 | 
            +
            			expect(Histample().history.size).to eq(0)
         | 
| 320 | 
            +
            			expect(Histample().history.last).to eq(nil)
         | 
| 321 | 
            +
            			
         | 
| 322 | 
            +
            		end
         | 
| 323 | 
            +
            		
         | 
| 324 | 
            +
            		it 'shows additional items upon inspection' do
         | 
| 325 | 
            +
             | 
| 326 | 
            +
            			extend Histample()
         | 
| 327 | 
            +
            			
         | 
| 328 | 
            +
            			expect(Histample().history.size).to eq(1)
         | 
| 329 | 
            +
            			expect(Histample().history.inspect).to match(/\[\(.+\|Histample\|\)\]/)
         | 
| 330 | 
            +
            			
         | 
| 331 | 
            +
            			eject Histample()
         | 
| 332 | 
            +
            			
         | 
| 333 | 
            +
            		end
         | 
| 334 | 
            +
            		
         | 
| 335 | 
            +
            		describe :precedent do
         | 
| 336 | 
            +
             | 
| 337 | 
            +
            			it 'points to the previous injector in the history' do
         | 
| 338 | 
            +
             | 
| 339 | 
            +
            				extend Histample(), Histample()
         | 
| 340 | 
            +
             | 
| 341 | 
            +
            				injectors.should == Histample().history
         | 
| 342 | 
            +
            				
         | 
| 343 | 
            +
            				expect(Histample().history.last.precedent).to equal(Histample().history.first)
         | 
| 344 | 
            +
            				expect(Histample().history.last.pre).to equal(injectors.first)
         | 
| 345 | 
            +
            				expect(injectors.last.precedent).to equal(Histample().history.first)
         | 
| 346 | 
            +
            				expect(injectors.last.pre).to equal(injectors.first)
         | 
| 347 | 
            +
            				expect(Histample().history.first.precedent).to equal(Histample().spec)
         | 
| 348 | 
            +
            				expect(injectors.first.precedent).to equal(Histample().spec)
         | 
| 349 | 
            +
            				expect(Histample().spec.pre).to eq(nil) 
         | 
| 350 | 
            +
            				
         | 
| 351 | 
            +
            				eject *injectors
         | 
| 352 | 
            +
             | 
| 353 | 
            +
            			end
         | 
| 354 | 
            +
             | 
| 355 | 
            +
            			it 'has <nil> as the precedent to spec' do
         | 
| 356 | 
            +
                    
         | 
| 357 | 
            +
            				expect(Histample().precedent).to equal(Histample().spec)
         | 
| 358 | 
            +
            				expect(Histample().spec.pre).to eq(nil) 
         | 
| 359 | 
            +
            				expect(Histample().pre.pre).to eq(nil)
         | 
| 360 | 
            +
            				
         | 
| 361 | 
            +
            			end
         | 
| 362 | 
            +
            			
         | 
| 363 | 
            +
            		end
         | 
| 364 | 
            +
            	end 
         | 
| 365 | 
            +
            	
         | 
| 366 | 
            +
            	describe :progenitor do
         | 
| 367 | 
            +
             | 
| 368 | 
            +
            		before do
         | 
| 369 | 
            +
            			injector :Progample
         | 
| 370 | 
            +
            		end
         | 
| 371 | 
            +
            		after do
         | 
| 372 | 
            +
            			Progample(:implode)
         | 
| 373 | 
            +
            		end
         | 
| 374 | 
            +
             | 
| 375 | 
            +
            		it 'points to its progenitor: the version of injector generating it' do
         | 
| 376 | 
            +
             | 
| 377 | 
            +
            			expect(Progample().history).to be_empty
         | 
| 378 | 
            +
            			expect(Progample().progenitor).to equal(Progample().spec)
         | 
| 379 | 
            +
             | 
| 380 | 
            +
            			extend Progample(), Progample()       
         | 
| 381 | 
            +
            			
         | 
| 382 | 
            +
            			expect(Progample().history.size).to eq(2)
         | 
| 383 | 
            +
            			expect(Progample().history.first.progenitor).to equal(Progample().spec)
         | 
| 384 | 
            +
            			expect(Progample().history.last.progenitor).to equal(Progample().spec)
         | 
| 385 | 
            +
             | 
| 386 | 
            +
            			suppress_warnings do
         | 
| 387 | 
            +
            				ProgenitorsTag = Progample()
         | 
| 388 | 
            +
            			end
         | 
| 389 | 
            +
             | 
| 390 | 
            +
            			expect(Progample().history.size).to eq(3)
         | 
| 391 | 
            +
            			expect(Progample().history.first.progenitor).to equal(Progample().spec)
         | 
| 392 | 
            +
            			expect(Progample().history.slice(1).progenitor).to equal(Progample().spec)
         | 
| 393 | 
            +
            			expect(Progample().history.last.progenitor).to equal(Progample().spec)
         | 
| 394 | 
            +
             | 
| 395 | 
            +
            			extend ProgenitorsTag
         | 
| 396 | 
            +
             | 
| 397 | 
            +
            			expect(Progample().history.size).to eq(4)
         | 
| 398 | 
            +
            			expect(Progample().history.last).to equal(injectors.last)
         | 
| 399 | 
            +
            			 
         | 
| 400 | 
            +
            			expect(Progample().history.last.progenitor).to equal(ProgenitorsTag) 
         | 
| 401 | 
            +
            			expect(Progample().history.last.progenitor).to equal(Progample().history.slice(2)) 
         | 
| 402 | 
            +
            			expect(Progample().history.slice(2).progenitor).to equal(Progample().spec)
         | 
| 403 | 
            +
            			expect(Progample().history.slice(1).progenitor).to equal(Progample().spec)
         | 
| 404 | 
            +
            			expect(Progample().history.first.progenitor).to equal(Progample().spec)
         | 
| 405 | 
            +
            			expect(Progample().spec.progenitor).to equal(nil)
         | 
| 406 | 
            +
            			expect(ProgenitorsTag.progenitor).to equal(Progample().spec)
         | 
| 407 | 
            +
            			expect(ProgenitorsTag.progenitor.progenitor).to equal(nil)
         | 
| 408 | 
            +
             | 
| 409 | 
            +
            			# eject *injectors
         | 
| 410 | 
            +
             | 
| 411 | 
            +
            		end
         | 
| 412 | 
            +
             | 
| 413 | 
            +
            		it 'should still pass' do
         | 
| 414 | 
            +
             | 
| 415 | 
            +
            			suppress_warnings do
         | 
| 416 | 
            +
            				ProgenitorsTag = Progample()
         | 
| 417 | 
            +
            			end
         | 
| 418 | 
            +
             | 
| 419 | 
            +
            			expect(Progample().history.size).to eq(1)
         | 
| 420 | 
            +
            			expect(Progample().history.slice(0)).to equal(ProgenitorsTag)
         | 
| 421 | 
            +
             | 
| 422 | 
            +
            			Progample(:tag) { 'some code'}       			# soft tag
         | 
| 423 | 
            +
             | 
| 424 | 
            +
            			expect(Progample().history.size).to eq(2)
         | 
| 425 | 
            +
            			expect(Progample().history.first).to equal(ProgenitorsTag)
         | 
| 426 | 
            +
            			expect(Progample().history.last).to eq(Progample())
         | 
| 427 | 
            +
            			expect(Progample().history.first.progenitor).to eq(Progample().spec)
         | 
| 428 | 
            +
            			expect(Progample().history.last.progenitor).to eq(Progample().spec)
         | 
| 429 | 
            +
            			expect(Progample().history.first.progenitor.progenitor).to eq(nil)
         | 
| 430 | 
            +
            			expect(Progample().history.last.progenitor.progenitor).to eq(nil)
         | 
| 431 | 
            +
            			expect(ProgenitorsTag.progenitor).to equal(Progample().spec)
         | 
| 432 | 
            +
            			expect(ProgenitorsTag.progenitor.progenitor).to equal(nil)
         | 
| 433 | 
            +
             | 
| 434 | 
            +
            			expect(Progample().tags.size).to eq(2)
         | 
| 435 | 
            +
             | 
| 436 | 
            +
            		end
         | 
| 437 | 
            +
             | 
| 438 | 
            +
            		it 'should pass' do
         | 
| 439 | 
            +
                  
         | 
| 440 | 
            +
            			suppress_warnings do
         | 
| 441 | 
            +
            				ProgenitorsTag = Progample()
         | 
| 442 | 
            +
            			end
         | 
| 443 | 
            +
             | 
| 444 | 
            +
            			class ProgenitorTester1
         | 
| 445 | 
            +
            				 include ProgenitorsTag
         | 
| 446 | 
            +
            			end
         | 
| 447 | 
            +
            			
         | 
| 448 | 
            +
            			class ProgenitorTester2
         | 
| 449 | 
            +
            				include *ProgenitorTester1.injectors
         | 
| 450 | 
            +
            			end
         | 
| 451 | 
            +
            			
         | 
| 452 | 
            +
            			expect(ProgenitorTester2.injectors.first.progenitor).to equal(ProgenitorTester1.injectors.first)
         | 
| 453 | 
            +
            			expect(ProgenitorTester1.injectors.first.progenitor).to equal(ProgenitorsTag)
         | 
| 454 | 
            +
            			expect(ProgenitorsTag.progenitor).to equal(Progample().spec)  
         | 
| 455 | 
            +
            			
         | 
| 456 | 
            +
            			with ProgenitorTester1 do
         | 
| 457 | 
            +
            				eject *injectors
         | 
| 458 | 
            +
            			end
         | 
| 459 | 
            +
            			
         | 
| 460 | 
            +
            			expect(ProgenitorTester2.injectors.first.progenitor).to equal(ProgenitorsTag)
         | 
| 461 | 
            +
            			expect(ProgenitorsTag.progenitor).to equal(Progample().spec)  
         | 
| 462 | 
            +
             | 
| 463 | 
            +
            		end
         | 
| 464 | 
            +
            		
         | 
| 465 | 
            +
            	end 
         | 
| 466 | 
            +
             | 
| 467 | 
            +
            	describe :lineage do 
         | 
| 468 | 
            +
            		
         | 
| 469 | 
            +
            		before do
         | 
| 470 | 
            +
            			injector :Lineample
         | 
| 471 | 
            +
            		end
         | 
| 472 | 
            +
            		after do
         | 
| 473 | 
            +
            			Lineample(:implode)
         | 
| 474 | 
            +
            		end
         | 
| 475 | 
            +
            		
         | 
| 476 | 
            +
            		it 'collects all the progenitors of a line of injectors' do 
         | 
| 477 | 
            +
            			
         | 
| 478 | 
            +
            			LineagesTag = Lineample()
         | 
| 479 | 
            +
             | 
| 480 | 
            +
            			class LineageTester1
         | 
| 481 | 
            +
            				 include LineagesTag
         | 
| 482 | 
            +
            			end
         | 
| 483 | 
            +
            			
         | 
| 484 | 
            +
            			class LineageTester2
         | 
| 485 | 
            +
            				include *LineageTester1.injectors
         | 
| 486 | 
            +
            			end
         | 
| 487 | 
            +
            			
         | 
| 488 | 
            +
            			expect(LineageTester2.injectors.first.progenitor).to equal(LineageTester1.injectors.first)
         | 
| 489 | 
            +
            			expect(LineageTester1.injectors.first.progenitor).to equal(LineagesTag)
         | 
| 490 | 
            +
            			expect(LineagesTag.progenitor).to equal(Lineample().spec)  
         | 
| 491 | 
            +
            			
         | 
| 492 | 
            +
            			expect(Lineample().lineage).to eq([Lineample().spec, Lineample()])
         | 
| 493 | 
            +
            			expect(LineageTester2.injectors.first.lineage).to eq([Lineample().spec, LineagesTag, LineageTester1.injectors.first, LineageTester2.injectors.first])
         | 
| 494 | 
            +
            			expect(Lineample().spec.lineage).to eq([Lineample().spec])
         | 
| 495 | 
            +
            			expect(Lineample().spec.progenitor).to eq(nil)
         | 
| 496 | 
            +
            			
         | 
| 497 | 
            +
            		end
         | 
| 498 | 
            +
             | 
| 499 | 
            +
            	end
         | 
| 500 | 
            +
             | 
| 501 | 
            +
            	describe 'equality of Injectors' do
         | 
| 502 | 
            +
            		
         | 
| 503 | 
            +
            		before do
         | 
| 504 | 
            +
            			injector :E
         | 
| 505 | 
            +
            			injector :F
         | 
| 506 | 
            +
            		end
         | 
| 507 | 
            +
            		
         | 
| 508 | 
            +
            		after do
         | 
| 509 | 
            +
            			E(:implode)
         | 
| 510 | 
            +
            			F(:implode)
         | 
| 511 | 
            +
            		end
         | 
| 512 | 
            +
            			 
         | 
| 513 | 
            +
            		# For now this is how equality is defined
         | 
| 514 | 
            +
            		describe 'equality' do
         | 
| 515 | 
            +
            			
         | 
| 516 | 
            +
            			it 'allows comparison between injectors' do
         | 
| 517 | 
            +
            				
         | 
| 518 | 
            +
            				E().should == E()
         | 
| 519 | 
            +
            				E().should_not == E().spec
         | 
| 520 | 
            +
            				
         | 
| 521 | 
            +
            				E(:tag).should == E()
         | 
| 522 | 
            +
            				ETag1 = E()
         | 
| 523 | 
            +
            				ETag1.should == E()
         | 
| 524 | 
            +
            				
         | 
| 525 | 
            +
            				extend E()
         | 
| 526 | 
            +
            				injectors.first.should == E()
         | 
| 527 | 
            +
            				
         | 
| 528 | 
            +
            				E() do
         | 
| 529 | 
            +
            					def foo                   # ** definition **
         | 
| 530 | 
            +
            					end
         | 
| 531 | 
            +
            				end     
         | 
| 532 | 
            +
            				
         | 
| 533 | 
            +
            				E().should == E()
         | 
| 534 | 
            +
            				ETag1.should_not == E()
         | 
| 535 | 
            +
            				injectors.first.should_not == E()
         | 
| 536 | 
            +
            				E(:tag).should == E()
         | 
| 537 | 
            +
            				
         | 
| 538 | 
            +
            				E().should_not == F()
         | 
| 539 | 
            +
            				
         | 
| 540 | 
            +
            			end
         | 
| 541 | 
            +
            			
         | 
| 542 | 
            +
            		end
         | 
| 543 | 
            +
            		
         | 
| 544 | 
            +
            		describe 'difference', :diff do
         | 
| 545 | 
            +
            		
         | 
| 546 | 
            +
            			it 'shows the difference between injectors' do
         | 
| 547 | 
            +
            			  
         | 
| 548 | 
            +
            				E().diff.should_not be_empty
         | 
| 549 | 
            +
            				# because
         | 
| 550 | 
            +
            				E().should_not == E().spec      # like above        
         | 
| 551 | 
            +
            		
         | 
| 552 | 
            +
            		
         | 
| 553 | 
            +
            				##################################
         | 
| 554 | 
            +
            				E().diff.should_not be_loaded
         | 
| 555 | 
            +
            				# because
         | 
| 556 | 
            +
            				E().diff.join.should be_empty
         | 
| 557 | 
            +
            				E().diff.delta.should_not be_empty
         | 
| 558 | 
            +
            		
         | 
| 559 | 
            +
            		
         | 
| 560 | 
            +
            				##################################
         | 
| 561 | 
            +
            				E().diff(E()).should be_empty  	
         | 
| 562 | 
            +
            				# because
         | 
| 563 | 
            +
            				E().should == E()               # like above
         | 
| 564 | 
            +
            				
         | 
| 565 | 
            +
            				ETag2 = E()
         | 
| 566 | 
            +
            				
         | 
| 567 | 
            +
            		
         | 
| 568 | 
            +
            				##################################
         | 
| 569 | 
            +
            				E().diff(ETag2).should be_empty
         | 
| 570 | 
            +
            				ETag2.diff(E()).should be_empty
         | 
| 571 | 
            +
            				# because 
         | 
| 572 | 
            +
            				ETag2.should == E() 						# like above
         | 
| 573 | 
            +
            				
         | 
| 574 | 
            +
            				E do
         | 
| 575 | 
            +
            					def foo 									# ** definition **
         | 
| 576 | 
            +
            					end
         | 
| 577 | 
            +
            				end
         | 
| 578 | 
            +
            				
         | 
| 579 | 
            +
            		
         | 
| 580 | 
            +
            				######################################
         | 
| 581 | 
            +
            				E().diff(ETag2).should_not be_empty
         | 
| 582 | 
            +
            				# because
         | 
| 583 | 
            +
            			  ETag2.should_not == E()        # like above
         | 
| 584 | 
            +
            				
         | 
| 585 | 
            +
            				E().diff(ETag2).delta.should == [:foo]
         | 
| 586 | 
            +
            				E().diff(ETag2).should be_loaded
         | 
| 587 | 
            +
            				# because
         | 
| 588 | 
            +
            				E().diff(ETag2).join.should == [:method_missing]
         | 
| 589 | 
            +
            				# and
         | 
| 590 | 
            +
            				E().diff(ETag2).delta.should == [:foo]
         | 
| 591 | 
            +
            		             
         | 
| 592 | 
            +
            		
         | 
| 593 | 
            +
            				######################################
         | 
| 594 | 
            +
            				E().diff.should be_loaded
         | 
| 595 | 
            +
            				# because 
         | 
| 596 | 
            +
            				E().diff.join.should == [:foo]
         | 
| 597 | 
            +
            				E().diff.delta.should == [:method_missing]
         | 
| 598 | 
            +
            				# because
         | 
| 599 | 
            +
            				E().diff.should all( eql(E()) )		# eql? does not take method differences
         | 
| 600 | 
            +
            				# and 
         | 
| 601 | 
            +
            				E().diff.map(&:instance_methods).should == [[:foo], [:method_missing]]  
         | 
| 602 | 
            +
            				# because
         | 
| 603 | 
            +
            				E().instance_methods.should == [:foo, :method_missing]
         | 
| 604 | 
            +
            				E().progenitor.instance_methods.should == [:foo]
         | 
| 605 | 
            +
            				# being that
         | 
| 606 | 
            +
            				E().progenitor.should equal(E().spec)
         | 
| 607 | 
            +
            				
         | 
| 608 | 
            +
            			end
         | 
| 609 | 
            +
            		end
         | 
| 610 | 
            +
            	
         | 
| 611 | 
            +
            	end
         | 
| 612 | 
            +
             | 
| 613 | 
            +
            end
         | 
| 614 | 
            +
             |