<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,6 @@ require 'model_stubbing/extensions'
 require 'model_stubbing/definition'
 require 'model_stubbing/model'
 require 'model_stubbing/stub'
-require 'model_stubbing/stub_proxy'
 
 module ModelStubbing
   # Gets a hash of all current definitions.</diff>
      <filename>lib/model_stubbing.rb</filename>
    </modified>
    <modified>
      <diff>@@ -112,7 +112,16 @@ module ModelStubbing
 
   protected
     def method_missing(model_name, stub_name, *args)
-      StubProxy.new(@definition, model_name, stub_name)
+      named_model = @definition.models[model_name]
+      if named_model.nil?
+        raise &quot;No #{model_name.inspect} model found when calling #{model_name}(#{stub_name})&quot;
+      end
+      stub = named_model.stubs[stub_name]
+      if stub.nil?
+        raise &quot;No #{stub_name.inspect} stub found in the #{model_name.inspect} model when calling #{model_name}(#{stub_name})&quot;
+      else
+        stub
+      end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/model_stubbing/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -47,13 +47,7 @@ module ModelStubbing
         ModelStubbing.records[this_record_key] = instantiate(this_record_key, attributes)
       end
     end
-
-    # Same as #record, but does not instantiate stubs.
-    def record_without_stubs
-      this_record_key = record_key(attributes)
-      instantiate(this_record_key, attributes, false)
-    end
-
+    
     def inspect
       &quot;(ModelStubbing::Stub(#{@name.inspect} =&gt; #{attributes.inspect}))&quot;
     end
@@ -75,7 +69,7 @@ module ModelStubbing
     def with(attributes)
       @attributes.inject({}) do |attr, (key, value)|
         attr_value = attributes[key] || value
-        attr_value = attr_value.record if (attr_value.is_a?(Stub) || attr_value.is_a?(StubProxy))
+        attr_value = attr_value.record if attr_value.is_a?(Stub)
         attr.update key =&gt; attr_value
       end
     end
@@ -84,7 +78,7 @@ module ModelStubbing
       keys = Set.new Array(keys)
       @attributes.inject({}) do |attr, (key, value)|
         if keys.include?(key)
-          attr.update key =&gt; ((value.is_a?(Stub) || value.is_a?(StubProxy)) ? value.record : value)
+          attr.update key =&gt; (value.is_a?(Stub) ? value.record : value)
         else
           attr
         end
@@ -97,7 +91,7 @@ module ModelStubbing
         if keys.include?(key)
           attr
         else
-          attr.update key =&gt; ((value.is_a?(Stub) || value.is_a?(StubProxy)) ? value.record : value)
+          attr.update key =&gt; (value.is_a?(Stub) ? value.record : value)
         end
       end
     end
@@ -105,14 +99,9 @@ module ModelStubbing
     def connection
       @connection ||= @model.connection
     end
-
-    # duck typing with StubProxy
-    def method_name
-      nil
-    end
-
+  
   private
-    def instantiate(this_record_key, attributes, with_stubs = true)
+    def instantiate(this_record_key, attributes)
       case attributes[:id] 
         when :new
           is_new_record = true
@@ -139,35 +128,26 @@ module ModelStubbing
       record.stubbed_attributes = stubbed_attributes.merge(:id =&gt; record.id)
       stubbed_attributes.each do |key, value|
         meta.send :attr_accessor, key unless record.respond_to?(&quot;#{key}=&quot;)
-        case value
-          when StubProxy, Stub
-            if with_stubs
-              if value.method_name
-                record.send(&quot;#{key}=&quot;, value.record_without_stubs)
-              else
-                # set foreign key
-                record.send(&quot;#{stubbed_attributes.column_name_for(key)}=&quot;, value.record_without_stubs.id)
-                # set association
-                record.send(&quot;#{key}=&quot;, value.record)
-              end
-            end
-          when Array
-            if with_stubs
-              records = value.map { |v| (v.is_a?(Stub) || v.is_a?(StubProxy)) ? v.record : v }
-              records.compact!
-              
-              # when assigning has_many instantiated stubs, temporarily act as new
-              # otherwise AR inserts rows
-              nr, record.new_record = record.new_record?, true
-              record.send(&quot;#{key}=&quot;, records)
-              record.new_record = nr
-            end
-          else
-            duped_value = case value
-              when TrueClass, FalseClass, Fixnum, Float, NilClass, Symbol then value
-              else value.dup
-            end
-            record.send(&quot;#{key}=&quot;, duped_value)
+        if value.is_a? Stub
+          # set foreign key
+          record.send(&quot;#{stubbed_attributes.column_name_for(key)}=&quot;, value.record.id)
+          # set association
+          record.send(&quot;#{key}=&quot;, value.record)
+        elsif value.is_a? Array
+          records = value.map { |v| v.is_a?(Stub) ? v.record : v }
+          records.compact!
+
+          # when assigning has_many instantiated stubs, temporarily act as new
+          # otherwise AR inserts rows
+          nr, record.new_record = record.new_record?, true
+          record.send(&quot;#{key}=&quot;, records)
+          record.new_record = nr
+        else
+          duped_value = case value
+            when TrueClass, FalseClass, Fixnum, Float, NilClass, Symbol then value
+            else value.dup
+          end
+          record.send(&quot;#{key}=&quot;, duped_value)
         end
       end
       record
@@ -202,11 +182,7 @@ module ModelStubbing
       list = inject([]) do |fixtures, (key, value)|
         column_name = column_name_for key
         column      = column_for column_name
-        case value
-          when Stub then value = value.record_without_stubs.id
-          when StubProxy
-            value = value.method_name ? value.record : value.record_without_stubs.id
-        end
+        value       = value.record.id if value.is_a?(Stub)
         quoted      = @stub.connection ? @stub.connection.quote(value, column) : %(&quot;#{value.to_s}&quot;)
         fixtures &lt;&lt; quoted.gsub('[^\]\\n', &quot;\n&quot;).gsub('[^\]\\r', &quot;\r&quot;)
       end.join(&quot;, &quot;)
@@ -215,12 +191,12 @@ module ModelStubbing
     def column_name_for(key)
       (@keys ||= {})[key] ||= begin
         value = self[key]
-        if value.is_a?(Stub) || value.is_a?(StubProxy)
+        if value.is_a? Stub
           if defined?(ActiveRecord)
             if reflection = model_class.reflect_on_association(key)
               reflection.primary_key_name
             else
-              &quot;#{key}_id&quot;.sub(/_id_id/, '_id')
+              raise &quot;No reflection '#{key}' found for #{model_class.name} while guessing column_name&quot;
             end
           else
             &quot;#{key}_id&quot;</diff>
      <filename>lib/model_stubbing/stub.rb</filename>
    </modified>
    <modified>
      <diff>@@ -81,11 +81,11 @@ module ModelStubbing
   
     it &quot;dups each model&quot; do
       @defn.models.each do |name, model|
-        duped_model   = @copy.models[name]
+        duped_model = @copy.models[name]
         model.should == duped_model
         model.should_not be_equal(duped_model)
         model.stubs.each do |key, stub|
-          duped_stub   = @copy.models[name].stubs[key]
+          duped_stub = @copy.models[name].stubs[key]
           stub.should == duped_stub
           stub.should_not be_equal(duped_stub)
         end
@@ -94,7 +94,7 @@ module ModelStubbing
   
     it &quot;dups each stub&quot; do
       @defn.stubs.each do |name, stub|
-        duped_stub   = @copy.stubs[name]
+        duped_stub = @copy.stubs[name]
         stub.should == duped_stub
         stub.should_not be_equal(duped_stub)
       end</diff>
      <filename>spec/definition_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -135,13 +135,13 @@ module ModelStubbing
     end
     
     model User do
-      stub :admin, :admin =&gt; true, :edited_post =&gt; model_stubbing_posts(:default) # inherits from default fixture
+      stub :admin, :admin =&gt; true # inherits from default fixture
     end
     
     model Post do
       # uses admin user fixture above
-      stub :title =&gt; 'initial', :user =&gt; model_stubbing_users(:admin), :published_at =&gt; current_time + 5.days, :editor_id =&gt; model_stubbing_users(:admin).id
-      stub :nice_one, :title =&gt; 'nice one', :tags =&gt; [model_stubbing_tags(:foo), model_stubbing_tags(:bar)]
+      stub :title =&gt; 'initial', :user =&gt; all_stubs(:admin_model_stubbing_user), :published_at =&gt; current_time + 5.days
+      stub :nice_one, :title =&gt; 'nice one', :tags =&gt; [all_stubs(:foo_model_stubbing_tag), all_stubs(:bar_model_stubbing_tag)]
     end
   end
   </diff>
      <filename>spec/models.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,11 +12,4 @@ rescue LoadError
   require 'spec'
 end
 
-begin
-  require 'ruby-debug'
-  Debugger.start
-rescue LoadError
-  # no debugger
-end
-
 require File.join(File.dirname(__FILE__), 'models')
\ No newline at end of file</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,6 @@ module ModelStubbing
       @posts      = @definition.models[:model_stubbing_posts]
       @user       = @users.default
       @post       = @posts.default
-      @editor_id  = StubProxy.new(@definition, @users.name, :admin, :id)
     end
 
     it &quot;is defined in stub file&quot; do
@@ -18,11 +17,11 @@ module ModelStubbing
   
     it &quot;has the default stub's attributes&quot; do
       @user.attributes.should == {:name =&gt; 'bob', :admin =&gt; false}
-      @post.attributes.should == {:title =&gt; 'initial', :user =&gt; @users.stubs[:admin], :editor_id =&gt; @editor_id, :published_at =&gt; @definition.current_time + 5.days}
+      @post.attributes.should == {:title =&gt; 'initial', :user =&gt; @users.stubs[:admin], :published_at =&gt; @definition.current_time + 5.days}
     end
   
     it &quot;#with returns merged attributes&quot; do
-      @post.with(:title =&gt; 'fred').should == {:title =&gt; 'fred', :user =&gt; @users.stubs[:admin].record, :editor_id =&gt; @editor_id.record, :published_at =&gt; @definition.current_time + 5.days}
+      @post.with(:title =&gt; 'fred').should == {:title =&gt; 'fred', :user =&gt; @users.stubs[:admin].record, :published_at =&gt; @definition.current_time + 5.days}
     end
   
     it &quot;#only returns only given keys&quot; do
@@ -30,11 +29,11 @@ module ModelStubbing
     end
   
     it &quot;#except returns other keys&quot; do
-      @post.except(:published_at).should == {:title =&gt; 'initial', :user =&gt; @users.stubs[:admin].record, :editor_id =&gt; @editor_id.record}
+      @post.except(:published_at).should == {:title =&gt; 'initial', :user =&gt; @users.stubs[:admin].record}
     end
   
     it &quot;merges named stub attributes with default attributes&quot; do
-      @users.stubs[:admin].attributes.should == {:name =&gt; 'bob', :admin =&gt; true, :edited_post =&gt; StubProxy.new(@definition, @posts.name, :default)}
+      @users.stubs[:admin].attributes.should == {:name =&gt; 'bob', :admin =&gt; true}
     end
   
     it &quot;sets default model stubs in the definition's global stubs&quot; do</diff>
      <filename>spec/stub_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/model_stubbing/stub_proxy.rb</filename>
    </removed>
    <removed>
      <filename>spec/stub_proxy_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>2d72b3d8396a3a6576185c2341cf2834198b8bdf</id>
    </parent>
  </parents>
  <author>
    <name>rick</name>
    <email>technoweenie@gmail.com</email>
  </author>
  <url>http://github.com/technoweenie/model_stubbing/commit/b52c68c767295580820cec74a201889fada9407a</url>
  <id>b52c68c767295580820cec74a201889fada9407a</id>
  <committed-date>2008-08-27T13:43:34-07:00</committed-date>
  <authored-date>2008-08-27T13:43:34-07:00</authored-date>
  <message>Revert &quot;added ModelDefinition::StubProxy so that you can relate stubs to other stubs that haven't been created yet.&quot;

This reverts commit 2d72b3d8396a3a6576185c2341cf2834198b8bdf.</message>
  <tree>80f7477768b95b8c75b78ddbd50dc7a8b7737a04</tree>
  <committer>
    <name>rick</name>
    <email>technoweenie@gmail.com</email>
  </committer>
</commit>
