<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,7 +20,13 @@ module Stubby
       
       def find_all(definition, key)
         key = nil if key == :all
-        key ? [find_one(definition, key)].compact : by_class(definition.class)
+        if key
+          [find_one(definition, key)].compact
+        else
+          definition.instantiate(:all) unless complete[definition.class]
+          complete[definition.class] = true
+          by_class(definition.class)
+        end
       end
     
       def find_one(definition, key)
@@ -38,6 +44,10 @@ module Stubby
         @by_key[klass] ||= {}
       end
       
+      def complete
+        @complete = {}
+      end
+      
       def store(klass, object, key)
         by_class(klass) &lt;&lt; object
         by_key(klass)[key] = object</diff>
      <filename>lib/stubby/instances.rb</filename>
    </modified>
    <modified>
      <diff>@@ -66,7 +66,7 @@ describe &quot;Stubby&quot; do
     it &quot;creates a class Stubby::Classes::Site::Site&quot; do
       lambda{ Stubby::Classes::Site::Site }.should_not raise_error
     end
-
+  
     it &quot;creates a class Stubby::Classes::Section::Root&quot; do
       lambda{ Stubby::Classes::Section::Root }.should_not raise_error
     end
@@ -75,7 +75,7 @@ describe &quot;Stubby&quot; do
       it &quot;responds to :save (as inherited from its base class)&quot; do
         Stubby::Classes::Site::Site.new.should respond_to(:save)
       end
-
+  
       it &quot;responds to :name&quot; do
         Stubby::Classes::Site::Site.new.should respond_to(:name)
       end
@@ -87,7 +87,7 @@ describe &quot;Stubby&quot; do
       it &quot;returns the first defined stub if no key is given&quot; do
         stub_site.name.should == 'site'
       end
-
+    
       it &quot;returns the stub referenced by a given key&quot; do
         stub_site(:another).name.should == 'another'
       end
@@ -98,16 +98,29 @@ describe &quot;Stubby&quot; do
     end
     
     describe &quot;with a plural lookup method&quot; do
-      it &quot;returns a collection of all stubs when no key is given&quot; do
-        stub_sites.should == [stub_site, stub_site(:another)]
-      end
-    
-      it &quot;returns a collection of all stubs when :all is given as a key&quot; do
-        stub_sites(:all).should == [stub_site, stub_site(:another)]
+      it &quot;returns an array containing all stubs when no key is given&quot; do
+        sites = stub_sites
+        sites.size.should == 2
+        sites.should == [stub_site, stub_site(:another)]
+      end
+          
+      it &quot;returns an array containing all stubs when :all is given as a key&quot; do
+        sites = stub_sites(:all)
+        sites.size.should == 2
+        sites.should == [stub_site, stub_site(:another)]
+      end
+          
+      it &quot;returns an array containing the referenced stub when a key is given&quot; do
+        sites = stub_sites(:another)
+        sites.size.should == 1
+        sites.should == [stub_site(:another)]
       end
-    
-      it &quot;returns a collection containing the referenced stub when a key is given&quot; do
-        stub_sites(:another).should == [stub_site(:another)]
+      
+      it &quot;returns an array containing all stubs even when a single stub has been looked up before&quot; do
+        stub_site
+        sites = stub_sites(:all)
+        sites.size.should == 2
+        sites.should == [stub_site, stub_site(:another)]
       end
     end
     
@@ -125,13 +138,13 @@ describe &quot;Stubby&quot; do
     it &quot;its target is an array of stub instances masquerading as a Site instance&quot; do
       @site.sections.should == stub_sections
     end
-
+  
     it &quot;works with rspec mock expectations&quot; do
       @site.sections.should_receive(:foo)
       @site.sections.foo
     end
   end
-
+  
   describe &quot;a method on a stub&quot; do
     before :each do
       @another = stub_site(:another)
@@ -189,24 +202,4 @@ describe &quot;Stubby&quot; do
     end
   end
 
-end
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+end
\ No newline at end of file</diff>
      <filename>spec/stubby_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f4b30262e71a66a68c39c3597624289622f8e330</id>
    </parent>
  </parents>
  <author>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </author>
  <url>http://github.com/svenfuchs/stubby/commit/52af8dc486aecccbb0fa41c81fdc2e40157ff8db</url>
  <id>52af8dc486aecccbb0fa41c81fdc2e40157ff8db</id>
  <committed-date>2008-05-29T14:13:38-07:00</committed-date>
  <authored-date>2008-05-29T14:13:38-07:00</authored-date>
  <message>bug in retrieving :all instances after a single instance has been retrieved before</message>
  <tree>844cb4b38c40d8ac6d4f61682cc96ad7a15f2651</tree>
  <committer>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </committer>
</commit>
