<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -81,7 +81,7 @@ class RspecNestedScaffoldGenerator &lt; Rails::Generator::NamedBase
         &quot;rspec_nested_scaffold:view_#{action}.#{@default_file_extension}&quot;,
         File.join('app/views', controller_class_path, controller_file_name, &quot;#{action}.#{default_file_extension}&quot;)
         )
-
+      
         m.template &quot;rspec_nested_scaffold:#{action}_erb_spec.rb&quot;,
         File.join('spec/views', controller_class_path, controller_file_name, &quot;#{action}.#{default_file_extension}_spec.rb&quot;)
       end</diff>
      <filename>generators/rspec_nested_scaffold/rspec_nested_scaffold_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,11 @@
 class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   
+  before_filter :load_&lt;%= nesting_owner %&gt;
+  
   protected
   
-  # The nested resource owner.
-  def &lt;%= nesting_owner %&gt;
-    @&lt;%=nesting_owner %&gt; ||= &lt;%= nesting_owner_class %&gt;.find(params[:&lt;%= nesting_owner %&gt;_id])
+  def load_&lt;%= nesting_owner %&gt;
+    @&lt;%=nesting_owner %&gt; = &lt;%= nesting_owner_class %&gt;.find(params[:&lt;%= nesting_owner %&gt;_id])
   end
   
   public
@@ -12,7 +13,7 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;.xml
   def index
-    @&lt;%= table_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(:all)
+    @&lt;%= table_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;
     
     respond_to do |format|
       format.html # index.html.erb
@@ -23,7 +24,7 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/1
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/1.xml
   def show
-    @&lt;%= file_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
+    @&lt;%= file_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
 
     respond_to do |format|
       format.html # show.html.erb
@@ -34,7 +35,7 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/new
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/new.xml
   def new
-    @&lt;%= file_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.build
+    @&lt;%= file_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.new
 
     respond_to do |format|
       format.html # new.html.erb
@@ -44,18 +45,18 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
 
   # GET /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/edit
   def edit
-    @&lt;%= file_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
+    @&lt;%= file_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
   end
 
   # POST /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;
   # POST /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;.xml
   def create
-    @&lt;%= file_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.build(params[:&lt;%= file_name %&gt;])
+    @&lt;%= file_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.new(params[:&lt;%= file_name %&gt;])
 
     respond_to do |format|
       if @&lt;%= file_name %&gt;.save
         flash[:notice] = '&lt;%= class_name %&gt; was successfully created.'
-        format.html { redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_url(&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;)) }
+        format.html { redirect_to([@&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;]) }
         format.xml  { render :xml =&gt; @&lt;%= file_name %&gt;, :status =&gt; :created, :location =&gt; &lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_path(&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;) }
       else
         format.html { render :action =&gt; &quot;new&quot; }
@@ -67,12 +68,12 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   # PUT /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/1
   # PUT /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/1.xml
   def update
-    @&lt;%= file_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
+    @&lt;%= file_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
 
     respond_to do |format|
       if @&lt;%= file_name %&gt;.update_attributes(params[:&lt;%= file_name %&gt;])
         flash[:notice] = '&lt;%= class_name %&gt; was successfully updated.'
-        format.html { redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_url(&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;)) }
+        format.html { redirect_to([@&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;]) }
         format.xml  { head :ok }
       else
         format.html { render :action =&gt; &quot;edit&quot; }
@@ -84,11 +85,11 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   # DELETE /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/1
   # DELETE /&lt;%=nesting_owner.pluralize%&gt;/:&lt;%=nesting_owner%&gt;_id/&lt;%= table_name %&gt;/1.xml
   def destroy
-    @&lt;%= file_name %&gt; = &lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
+    @&lt;%= file_name %&gt; = @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.find(params[:id])
     @&lt;%= file_name %&gt;.destroy
 
     respond_to do |format|
-      format.html { redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= table_name %&gt;_path(&lt;%= nesting_owner %&gt;)) }
+      format.html { redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= table_name %&gt;_path(@&lt;%= nesting_owner %&gt;)) }
       format.xml  { head :ok }
     end
   end</diff>
      <filename>generators/rspec_nested_scaffold/templates/controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,336 +1,181 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../spec_helper')
 
 describe &lt;%= controller_class_name %&gt;Controller do
-  before(:each) do
-    @&lt;%= file_name %&gt; = mock_model(&lt;%= class_name %&gt;, :to_param =&gt; '1')
-    @&lt;%= nesting_owner %&gt; = mock_model(&lt;%= nesting_owner_class %&gt;, :&lt;%= table_name %&gt; =&gt; [@&lt;%= file_name %&gt;], :to_param =&gt; '2')
-    &lt;%= nesting_owner_class %&gt;.stub!(:find).with('2').and_return(@&lt;%= nesting_owner %&gt;)
-  end
-
-  describe &quot;handling GET /&lt;%= nesting_owner %&gt;s/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;&quot; do
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).with(:all).and_return([@&lt;%= file_name %&gt;])
-    end
-    def do_get
-      get :index, :&lt;%= nesting_owner %&gt;_id =&gt; '2'
-    end
-
-    it &quot;should be successful&quot; do
-      do_get
-      response.should be_success
-    end
-
-    it &quot;should assign the found &lt;%= nesting_owner %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= nesting_owner %&gt;].should == @&lt;%= nesting_owner %&gt;
-    end
-
-    it &quot;should render index template&quot; do
-      do_get
-      response.should render_template('index')
-    end
-
-    it &quot;should find all &lt;%= table_name %&gt; owned by &lt;%= nesting_owner %&gt;&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).with(:all).and_return([@&lt;%= file_name %&gt;])
-      do_get
-    end
 
-    it &quot;should assign the found &lt;%= table_name %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= table_name %&gt;].should == [@&lt;%= file_name %&gt;]
-    end
+  def mock_&lt;%= file_name %&gt;(stubs={})
+    @mock_&lt;%= file_name %&gt; ||= mock_model(&lt;%= class_name %&gt;, stubs)
   end
-
-  describe &quot;handling GET /&lt;%= nesting_owner %&gt;s/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;.xml&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return([@&lt;%= file_name %&gt;])
-    end
-
-    def do_get
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:to_xml).and_return(&quot;XML&quot;)
-      @&lt;%= file_name %&gt;.stub!(:to_xml).and_return(&quot;XML&quot;)
-      @request.env[&quot;HTTP_ACCEPT&quot;] = &quot;application/xml&quot;
-      get :index, :&lt;%= nesting_owner %&gt;_id =&gt; '2'
-    end
-
-    it &quot;should be successful&quot; do
-      do_get
-      response.should be_success
-    end
-
-    it &quot;should find all &lt;%= table_name %&gt;&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).and_return([@&lt;%= file_name %&gt;])
-      do_get
-    end
-
-    it &quot;should render the found &lt;%= table_name %&gt; as xml&quot; do
-      @&lt;%= file_name %&gt;.should_receive(:to_xml).and_return(&quot;XML&quot;)
-      do_get
-    end
+  
+  def mock_&lt;%= nesting_owner %&gt;(stubs={})
+    @mock_&lt;%= nesting_owner %&gt; ||= mock_model(&lt;%= nesting_owner_class %&gt;, stubs.reverse_merge(:&lt;%= table_name %&gt; =&gt; mock('Array of &lt;%= class_name.pluralize %&gt;')))
   end
-
-  describe &quot;handling GET /&lt;%= nesting_owner %&gt;s/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;/1&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-    end
-
-    def do_get
-      get :show, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; '1'
-    end
-
-    it &quot;should be successful&quot; do
-      do_get
-      response.should be_success
-    end
-
-    it &quot;should render show template&quot; do
-      do_get
-      response.should render_template('show')
-    end
-
-    it &quot;should find the &lt;%= file_name %&gt; requested&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-      do_get
-    end
-
-    it &quot;should assign the found &lt;%= file_name %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= file_name %&gt;].should equal(@&lt;%= file_name %&gt;)
-    end
-
-    it &quot;should assign the found &lt;%= nesting_owner %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= nesting_owner %&gt;].should == @&lt;%= nesting_owner %&gt;
-    end
-
+  
+  before(:each) do
+    &lt;%= nesting_owner_class %&gt;.stub!(:find).with(&quot;1&quot;).and_return(mock_&lt;%= nesting_owner %&gt;)
   end
-
-  describe &quot;handling GET /&lt;%= nesting_owner %&gt;s/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;/1.xml&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-    end
-
-    def do_get
-      @request.env[&quot;HTTP_ACCEPT&quot;] = &quot;application/xml&quot;
-      get :show, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; '1'
-    end
-
-    it &quot;should be successful&quot; do
-      do_get
-      response.should be_success
-    end
-
-    it &quot;should find the &lt;%= file_name %&gt; requested&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-      do_get
+    
+  describe &quot;responding to GET index&quot; do
+
+    it &quot;should expose all &lt;%= table_name.pluralize %&gt; as @&lt;%= table_name.pluralize %&gt;&quot; do
+      mock_&lt;%= nesting_owner %&gt;.should_receive(:&lt;%= table_name %&gt;).with(no_args).and_return([mock_&lt;%= file_name %&gt;])
+      get :index, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+      assigns[:&lt;%= table_name %&gt;].should == [mock_&lt;%= file_name %&gt;]
+    end
+
+    describe &quot;with mime type of xml&quot; do
+  
+      it &quot;should render all &lt;%= table_name.pluralize %&gt; as xml&quot; do
+        request.env[&quot;HTTP_ACCEPT&quot;] = &quot;application/xml&quot;
+        mock_&lt;%= nesting_owner %&gt;.should_receive(:&lt;%= table_name %&gt;).with(no_args).and_return(&lt;%= file_name.pluralize %&gt; = mock(&quot;Array of &lt;%= class_name.pluralize %&gt;&quot;))
+        &lt;%= table_name %&gt;.should_receive(:to_xml).and_return(&quot;generated XML&quot;)
+        get :index, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        response.body.should == &quot;generated XML&quot;
+      end
+    
     end
 
-    it &quot;should render the found &lt;%= file_name %&gt; as xml&quot; do
-      @&lt;%= file_name %&gt;.stub!(:to_xml).and_return(&quot;XML&quot;)
-      do_get
-      response.body.should == &quot;XML&quot;
-    end
   end
 
-  describe &quot;handling GET /&lt;%= nesting_owner %&gt;s/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;/new&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:build).and_return(@&lt;%= file_name %&gt;)
-    end
+  describe &quot;responding to GET show&quot; do
 
-    def do_get
-      get :new, :&lt;%= nesting_owner %&gt;_id =&gt; '2'
+    it &quot;should expose the requested &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+      mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with(&quot;37&quot;).and_return(mock_&lt;%= file_name %&gt;)
+      get :show, :id =&gt; &quot;37&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+      assigns[:&lt;%= file_name %&gt;].should equal(mock_&lt;%= file_name %&gt;)
     end
+    
+    describe &quot;with mime type of xml&quot; do
 
-    it &quot;should be successful&quot; do
-      do_get
-      response.should be_success
-    end
-
-    it &quot;should render new template&quot; do
-      do_get
-      response.should render_template('new')
-    end
-
-    it &quot;should create an new &lt;%= file_name %&gt;&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:build).and_return(@&lt;%= file_name %&gt;)
-      do_get
-    end
-
-    it &quot;should not save the new &lt;%= file_name %&gt;&quot; do
-      @&lt;%= file_name %&gt;.should_not_receive(:save)
-      do_get
-    end
-
-    it &quot;should assign the new &lt;%= file_name %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= file_name %&gt;].should equal(@&lt;%= file_name %&gt;)
-    end
+      it &quot;should render the requested &lt;%= file_name %&gt; as xml&quot; do
+        request.env[&quot;HTTP_ACCEPT&quot;] = &quot;application/xml&quot;
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with(&quot;37&quot;).and_return(mock_&lt;%= file_name %&gt;)
+        mock_&lt;%= file_name %&gt;.should_receive(:to_xml).and_return(&quot;generated XML&quot;)
+        get :show, :id =&gt; &quot;37&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        response.body.should == &quot;generated XML&quot;
+      end
 
-    it &quot;should assign the &lt;%= nesting_owner_class %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= nesting_owner %&gt;].should equal(@&lt;%= nesting_owner %&gt;)
     end
+    
   end
 
-  describe &quot;handling GET /&lt;%= nesting_owner %&gt;s/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;/1/edit&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(@&lt;%= file_name %&gt;)
-    end
-
-    def do_get
-      get :edit, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; '1'
-    end
-
-    it &quot;should be successful&quot; do
-      do_get
-      response.should be_success
-    end
-
-    it &quot;should render edit template&quot; do
-      do_get
-      response.should render_template('edit')
-    end
-
-    it &quot;should find the &lt;%= file_name %&gt; requested&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-      do_get
-    end
-
-    it &quot;should assign the found &lt;%= class_name %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= file_name %&gt;].should equal(@&lt;%= file_name %&gt;)
+  describe &quot;responding to GET new&quot; do
+  
+    it &quot;should expose a new &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+      mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:new).and_return(mock_&lt;%= file_name %&gt;)
+      get :new, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+      assigns[:&lt;%= file_name %&gt;].should equal(mock_&lt;%= file_name %&gt;)
     end
 
-    it &quot;should assign the &lt;%= nesting_owner_class %&gt; for the view&quot; do
-      do_get
-      assigns[:&lt;%= nesting_owner %&gt;].should equal(@&lt;%= nesting_owner %&gt;)
-    end
   end
 
-  describe &quot;handling POST /&lt;%= nesting_owner.pluralize %&gt;/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:build).and_return(@&lt;%= file_name %&gt;)
+  describe &quot;responding to GET edit&quot; do
+  
+    it &quot;should expose the requested &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+      mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with(&quot;37&quot;).and_return(mock_&lt;%= file_name %&gt;)
+      get :edit, :id =&gt; &quot;37&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+      assigns[:&lt;%= file_name %&gt;].should equal(mock_&lt;%= file_name %&gt;)
     end
 
-    describe &quot;with successful save&quot; do
+  end
 
-      def do_post
-        @&lt;%= file_name %&gt;.should_receive(:save).and_return(true)
-        post :create, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :&lt;%= file_name %&gt; =&gt; {}
-      end
+  describe &quot;responding to POST create&quot; do
 
-      it &quot;should create a new &lt;%= file_name %&gt;&quot; do
-        @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:build).with({}).and_return(@&lt;%= file_name %&gt;)
-        do_post
+    describe &quot;with valid params&quot; do
+      
+      it &quot;should expose a newly created &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:new).with({'these' =&gt; 'params'}).and_return(mock_&lt;%= file_name %&gt;(:save =&gt; true))
+        post :create, :&lt;%= file_name %&gt; =&gt; {:these =&gt; 'params'}, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        assigns(:&lt;%= file_name %&gt;).should equal(mock_&lt;%= file_name %&gt;)
       end
 
-      it &quot;should redirect to the new &lt;%= file_name %&gt;&quot; do
-        do_post
-        response.should redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_path(@&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;))
+      it &quot;should redirect to the created &lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:new).and_return(mock_&lt;%= file_name %&gt;(:save =&gt; true))
+        post :create, :&lt;%= file_name %&gt; =&gt; {}, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        response.should redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_url(mock_&lt;%= nesting_owner %&gt;, mock_&lt;%= file_name %&gt;))
       end
-
+      
     end
+    
+    describe &quot;with invalid params&quot; do
 
-    describe &quot;with failed save&quot; do
-
-      def do_post
-        @&lt;%= file_name %&gt;.should_receive(:save).and_return(false)
-        post :create, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :&lt;%= file_name %&gt; =&gt; {}
+      it &quot;should expose a newly created but unsaved &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:new).with({'these' =&gt; 'params'}).and_return(mock_&lt;%= file_name %&gt;(:save =&gt; false))
+        post :create, :&lt;%= file_name %&gt; =&gt; {:these =&gt; 'params'}, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        assigns(:&lt;%= file_name %&gt;).should equal(mock_&lt;%= file_name %&gt;)
       end
 
-      it &quot;should re-render 'new'&quot; do
-        do_post
+      it &quot;should re-render the 'new' template&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:new).and_return(mock_&lt;%= file_name %&gt;(:save =&gt; false))
+        post :create, :&lt;%= file_name %&gt; =&gt; {}, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
         response.should render_template('new')
       end
-
+      
     end
+    
   end
 
-  describe &quot;handling PUT /&lt;%= nesting_owner.pluralize %&gt;/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;/1&quot; do
-
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(@&lt;%= file_name %&gt;)
-    end
-
-    describe &quot;with successful update&quot; do
-
-      def do_put
-        @&lt;%= file_name %&gt;.should_receive(:update_attributes).and_return(true)
-        put :update, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; '1'
-      end
-
-      it &quot;should find the &lt;%= file_name %&gt; requested&quot; do
-        @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-        do_put
-      end
+  describe &quot;responding to PUT udpate&quot; do
 
-      it &quot;should update the found &lt;%= file_name %&gt;&quot; do
-        do_put
-        assigns(:&lt;%= file_name %&gt;).should equal(@&lt;%= file_name %&gt;)
-      end
+    describe &quot;with valid params&quot; do
 
-      it &quot;should assign the found &lt;%= file_name %&gt; for the view&quot; do
-        do_put
-        assigns(:&lt;%= file_name %&gt;).should equal(@&lt;%= file_name %&gt;)
+      it &quot;should update the requested &lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with(&quot;37&quot;).and_return(mock_&lt;%= file_name %&gt;)
+        mock_&lt;%= file_name %&gt;.should_receive(:update_attributes).with({'these' =&gt; 'params'})
+        put :update, :id =&gt; &quot;37&quot;, :&lt;%= file_name %&gt; =&gt; {:these =&gt; 'params'}, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
       end
 
-      it &quot;should assign the &lt;%= nesting_owner %&gt; for the view&quot; do
-        do_put
-        assigns(:&lt;%= nesting_owner %&gt;).should equal(@&lt;%= nesting_owner %&gt;)
+      it &quot;should expose the requested &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(mock_&lt;%= file_name %&gt;(:update_attributes =&gt; true))
+        put :update, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        assigns(:&lt;%= file_name %&gt;).should equal(mock_&lt;%= file_name %&gt;)
       end
 
       it &quot;should redirect to the &lt;%= file_name %&gt;&quot; do
-        do_put
-        response.should redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_url(@&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;))
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(mock_&lt;%= file_name %&gt;(:update_attributes =&gt; true))
+        put :update, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        response.should redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_url(mock_&lt;%= nesting_owner %&gt;, mock_&lt;%= file_name %&gt;))
       end
 
     end
+    
+    describe &quot;with invalid params&quot; do
 
-    describe &quot;with failed update&quot; do
+      it &quot;should update the requested &lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with(&quot;37&quot;).and_return(mock_&lt;%= file_name %&gt;)
+        mock_&lt;%= file_name %&gt;.should_receive(:update_attributes).with({'these' =&gt; 'params'})
+        put :update, :id =&gt; &quot;37&quot;, :&lt;%= file_name %&gt; =&gt; {:these =&gt; 'params'}, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+      end
 
-      def do_put
-        @&lt;%= file_name %&gt;.should_receive(:update_attributes).and_return(false)
-        put :update, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; '1'
+      it &quot;should expose the &lt;%= file_name %&gt; as @&lt;%= file_name %&gt;&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(mock_&lt;%= file_name %&gt;(:update_attributes =&gt; false))
+        put :update, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+        assigns(:&lt;%= file_name %&gt;).should equal(mock_&lt;%= file_name %&gt;)
       end
 
-      it &quot;should re-render 'edit'&quot; do
-        do_put
+      it &quot;should re-render the 'edit' template&quot; do
+        mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(mock_&lt;%= file_name %&gt;(:update_attributes =&gt; false))
+        put :update, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
         response.should render_template('edit')
       end
 
     end
-  end
-
-  describe &quot;handling DELETE /&lt;%= nesting_owner.pluralize %&gt;/:&lt;%= nesting_owner %&gt;_id/&lt;%= table_name %&gt;/1&quot; do
 
-    before(:each) do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(@&lt;%= file_name %&gt;)
-      @&lt;%= file_name %&gt;.stub!(:destroy).and_return(true)
-    end
+  end
 
-    def do_delete
-      delete :destroy, :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; '1'
-    end
+  describe &quot;responding to DELETE destroy&quot; do
 
-    it &quot;should find the &lt;%= file_name %&gt; requested&quot; do
-      @&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with('1').and_return(@&lt;%= file_name %&gt;)
-      do_delete
+    it &quot;should destroy the requested &lt;%= file_name %&gt;&quot; do
+      mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.should_receive(:find).with(&quot;37&quot;).and_return(mock_&lt;%= file_name %&gt;)
+      mock_&lt;%= file_name %&gt;.should_receive(:destroy)
+      delete :destroy, :id =&gt; &quot;37&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
     end
-
-    it &quot;should call destroy on the found &lt;%= file_name %&gt;&quot; do
-      @&lt;%= file_name %&gt;.should_receive(:destroy)
-      do_delete
+  
+    it &quot;should redirect to the &lt;%= table_name %&gt; list&quot; do
+      mock_&lt;%= nesting_owner %&gt;.&lt;%= table_name %&gt;.stub!(:find).and_return(mock_&lt;%= file_name %&gt;(:destroy =&gt; true))
+      delete :destroy, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;
+      response.should redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= table_name %&gt;_url(mock_&lt;%= nesting_owner %&gt;))
     end
 
-    it &quot;should redirect to the &lt;%= nesting_owner %&gt;'s &lt;%= table_name %&gt; list&quot; do
-      do_delete
-      response.should redirect_to(&lt;%= nesting_owner %&gt;_&lt;%= table_name %&gt;_url(@&lt;%= nesting_owner %&gt;))
-    end
   end
+
 end</diff>
      <filename>generators/rspec_nested_scaffold/templates/controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,25 +1,22 @@
-require File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper')
 
 describe &quot;/&lt;%= table_name %&gt;/edit.&lt;%= default_file_extension %&gt;&quot; do
   include &lt;%= controller_class_name %&gt;Helper
   
-  before do
-    @&lt;%= file_name %&gt; = mock_model(&lt;%= class_name %&gt;)
-    @&lt;%= nesting_owner %&gt; = mock_model(&lt;%= nesting_owner_class %&gt;)
-&lt;% for attribute in attributes -%&gt;
-    @&lt;%= file_name %&gt;.stub!(:&lt;%= attribute.name %&gt;).and_return(&lt;%= attribute.default_value %&gt;)
-&lt;% end -%&gt;
-    assigns[:&lt;%= file_name %&gt;] = @&lt;%= file_name %&gt;
-    assigns[:&lt;%= nesting_owner %&gt;] = @&lt;%= nesting_owner %&gt;
+  before(:each) do
+    assigns[:&lt;%= nesting_owner %&gt;] = @&lt;%= nesting_owner %&gt; = stub_model(&lt;%= nesting_owner_class %&gt;)
+    assigns[:&lt;%= file_name %&gt;] = @&lt;%= file_name %&gt; = stub_model(&lt;%= class_name %&gt;,
+      :new_record? =&gt; false&lt;%= attributes.empty? ? '' : ',' %&gt;
+&lt;% attributes.each_with_index do |attribute, attribute_index| -%&gt;&lt;% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%&gt;
+      :&lt;%= attribute.name %&gt; =&gt; &lt;%= attribute.default_value %&gt;&lt;%= attribute_index == attributes.length - 1 ? '' : ','%&gt;
+&lt;% end -%&gt;&lt;% end -%&gt;
+    )
   end
 
   it &quot;should render edit form&quot; do
     render &quot;/&lt;%= table_name %&gt;/edit.&lt;%= default_file_extension %&gt;&quot;
     
     response.should have_tag(&quot;form[action=#{&lt;%= nesting_owner %&gt;_&lt;%= file_name %&gt;_path(@&lt;%= nesting_owner %&gt;, @&lt;%= file_name %&gt;)}][method=post]&quot;) do
-      with_tag('div[style=?]', &quot;margin:0;padding:0&quot;) do
-        with_tag('input[name=_method][type=hidden][value=put]')
-      end
 &lt;% for attribute in attributes -%&gt;&lt;% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%&gt;
       with_tag('&lt;%= attribute.input_type -%&gt;#&lt;%= file_name %&gt;_&lt;%= attribute.name %&gt;[name=?]', &quot;&lt;%= file_name %&gt;[&lt;%= attribute.name %&gt;]&quot;)
 &lt;% end -%&gt;&lt;% end -%&gt;</diff>
      <filename>generators/rspec_nested_scaffold/templates/edit_erb_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,21 @@
-require File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper')
 
 describe &quot;/&lt;%= table_name %&gt;/index.&lt;%= default_file_extension %&gt;&quot; do
   include &lt;%= controller_class_name %&gt;Helper
   
   before(:each) do
-&lt;% [98,99].each do |id| -%&gt;
-    &lt;%= file_name %&gt;_&lt;%= id %&gt; = mock_model(&lt;%= class_name %&gt;)
-&lt;% for attribute in attributes -%&gt;
-    &lt;%= file_name %&gt;_&lt;%= id %&gt;.should_receive(:&lt;%= attribute.name %&gt;).and_return(&lt;%= attribute.default_value %&gt;)
-&lt;% end -%&gt;&lt;% end %&gt;
-    @&lt;%= nesting_owner %&gt; = mock_model(&lt;%= nesting_owner_class %&gt;)
-    assigns[:&lt;%= table_name %&gt;] = [&lt;%= file_name %&gt;_98, &lt;%= file_name %&gt;_99]
-    assigns[:&lt;%= nesting_owner %&gt;] = @&lt;%= nesting_owner %&gt;
+    assigns[:&lt;%= nesting_owner %&gt;] = stub_model(&lt;%= nesting_owner_class %&gt;)
+    assigns[:&lt;%= table_name %&gt;] = [
+&lt;% [1,2].each_with_index do |id, model_index| -%&gt;
+      stub_model(&lt;%= class_name %&gt;&lt;%= attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %&gt;
+&lt;% attributes.each_with_index do |attribute, attribute_index| -%&gt;&lt;% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%&gt;
+        :&lt;%= attribute.name %&gt; =&gt; &lt;%= attribute.default_value %&gt;&lt;%= attribute_index == attributes.length - 1 ? '' : ','%&gt;
+&lt;% end -%&gt;&lt;% end -%&gt;
+&lt;% if !attributes.empty? -%&gt;
+      &lt;%= model_index == 1 ? ')' : '),' %&gt;
+&lt;% end -%&gt;
+&lt;% end -%&gt;
+    ]
   end
 
   it &quot;should render list of &lt;%= table_name %&gt;&quot; do
@@ -21,4 +25,3 @@ describe &quot;/&lt;%= table_name %&gt;/index.&lt;%= default_file_extension %&gt;&quot; do
 &lt;% end -%&gt;&lt;% end -%&gt;
   end
 end
-</diff>
      <filename>generators/rspec_nested_scaffold/templates/index_erb_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,24 +1,22 @@
-require File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper')
 
 describe &quot;/&lt;%= table_name %&gt;/new.&lt;%= default_file_extension %&gt;&quot; do
   include &lt;%= controller_class_name %&gt;Helper
   
   before(:each) do
-    @&lt;%= file_name %&gt; = mock_model(&lt;%= class_name %&gt;)
-    @&lt;%= file_name %&gt;.stub!(:new_record?).and_return(true)
-    @&lt;%= nesting_owner %&gt; = mock_model(&lt;%= nesting_owner_class %&gt;)
-&lt;% for attribute in attributes -%&gt;
-    @&lt;%= file_name %&gt;.stub!(:&lt;%= attribute.name %&gt;).and_return(&lt;%= attribute.default_value %&gt;)
-&lt;% end -%&gt;
-    assigns[:&lt;%= file_name %&gt;] = @&lt;%= file_name %&gt;
-    assigns[:&lt;%= nesting_owner %&gt;] = @&lt;%= nesting_owner %&gt;    
+    assigns[:&lt;%= nesting_owner %&gt;] = @&lt;%= nesting_owner %&gt; = stub_model(&lt;%= nesting_owner_class %&gt;)
+    assigns[:&lt;%= file_name %&gt;] = stub_model(&lt;%= class_name %&gt;,
+      :new_record? =&gt; true&lt;%= attributes.empty? ? '' : ',' %&gt;
+&lt;% attributes.each_with_index do |attribute, attribute_index| -%&gt;&lt;% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%&gt;
+      :&lt;%= attribute.name %&gt; =&gt; &lt;%= attribute.default_value %&gt;&lt;%= attribute_index == attributes.length - 1 ? '' : ','%&gt;
+&lt;% end -%&gt;&lt;% end -%&gt;
+    )
   end
 
   it &quot;should render new form&quot; do
     render &quot;/&lt;%= table_name %&gt;/new.&lt;%= default_file_extension %&gt;&quot;
     
     response.should have_tag(&quot;form[action=?][method=post]&quot;, &lt;%= nesting_owner %&gt;_&lt;%= table_name %&gt;_path(@&lt;%= nesting_owner %&gt;)) do
-      with_tag('input[name=_method][type=hidden][value=put]', :count =&gt; 0)
 &lt;% for attribute in attributes -%&gt;&lt;% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%&gt;
       with_tag(&quot;&lt;%= attribute.input_type -%&gt;#&lt;%= file_name %&gt;_&lt;%= attribute.name %&gt;[name=?]&quot;, &quot;&lt;%= file_name %&gt;[&lt;%= attribute.name %&gt;]&quot;)
 &lt;% end -%&gt;&lt;% end -%&gt;</diff>
      <filename>generators/rspec_nested_scaffold/templates/new_erb_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,61 +1,59 @@
-require File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../spec_helper')
 
 describe &lt;%= controller_class_name %&gt;Controller do
   describe &quot;route generation&quot; do
-
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;',  :action =&gt; 'index', :&lt;%= nesting_owner %&gt;_id =&gt; '2' } to /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;&quot; do
-      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'index', :&lt;%= nesting_owner %&gt;_id =&gt; '2').should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;&quot;
+    it &quot;should map #index&quot; do
+      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;index&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;',  :action =&gt; 'new', :&lt;%= nesting_owner %&gt;_id =&gt; '2' } to /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/new&quot; do
-      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'new', :&lt;%= nesting_owner %&gt;_id =&gt; '2').should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/new&quot;
+    it &quot;should map #new&quot; do
+      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;new&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/new&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;',  :action =&gt; 'show', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1 } to /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot; do
-      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'show', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot;
+    it &quot;should map #show&quot; do
+      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;show&quot;, :id =&gt; 1, :&lt;%= nesting_owner %&gt;_id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;',  :action =&gt; 'edit', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1 } to /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot; do
-      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'edit', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot;
+    it &quot;should map #edit&quot; do
+      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;edit&quot;, :id =&gt; 1, :&lt;%= nesting_owner %&gt;_id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;',  :action =&gt; 'update', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1} to /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot; do
-      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'update', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot;
+    it &quot;should map #update&quot; do
+      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;update&quot;, :id =&gt; 1, :&lt;%= nesting_owner %&gt;_id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;',  :action =&gt; 'destroy', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1} to /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot; do
-      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'destroy', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot;
+    it &quot;should map #destroy&quot; do
+      route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;destroy&quot;, :id =&gt; 1, :&lt;%= nesting_owner %&gt;_id =&gt; 1).should == &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&quot;
     end
   end
 
   describe &quot;route recognition&quot; do
-
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'index', :&lt;%= nesting_owner %&gt;_id =&gt; '2' } from GET /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;&quot; do
-      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'index', :&lt;%= nesting_owner %&gt;_id =&gt; '2'}
+    it &quot;should generate params for #index&quot; do
+      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;index&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'new', :&lt;%= nesting_owner %&gt;_id =&gt; '2' } from GET /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/new&quot; do
-      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/new&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'new', :&lt;%= nesting_owner %&gt;_id =&gt; '2'}
+    it &quot;should generate params for #new&quot; do
+      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/new&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;new&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'create', :&lt;%= nesting_owner %&gt;_id =&gt; '2' } from POST /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;&quot; do
-      params_from(:post, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'create', :&lt;%= nesting_owner %&gt;_id =&gt; '2'}
+    it &quot;should generate params for #create&quot; do
+      params_from(:post, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;create&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'show', :&lt;%= nesting_owner %&gt;_id =&gt; '2', id =&gt; '1' } from GET /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot; do
-      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'show', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; &quot;1&quot;}
+    it &quot;should generate params for #show&quot; do
+      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;show&quot;, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'edit', :&lt;%= nesting_owner %&gt;_id =&gt; '2', id =&gt; '1' } from GET /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1;edit&quot; do
-      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'edit', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; &quot;1&quot;}
+    it &quot;should generate params for #edit&quot; do
+      params_from(:get, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;edit&quot;, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'update', :&lt;%= nesting_owner %&gt;_id =&gt; '2', id =&gt; '1' } from PUT /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot; do
-      params_from(:put, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'update', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; &quot;1&quot;}
+    it &quot;should generate params for #update&quot; do
+      params_from(:put, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;update&quot;, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'destroy', :&lt;%= nesting_owner %&gt;_id =&gt; '2', id =&gt; '1' } from DELETE /&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot; do
-      params_from(:delete, &quot;/&lt;%= nesting_owner.pluralize %&gt;/2/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;,  :action =&gt; 'destroy', :&lt;%= nesting_owner %&gt;_id =&gt; '2', :id =&gt; &quot;1&quot;}
+    it &quot;should generate params for #destroy&quot; do
+      params_from(:delete, &quot;/&lt;%= nesting_owner.pluralize %&gt;/1/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;destroy&quot;, :id =&gt; &quot;1&quot;, :&lt;%= nesting_owner %&gt;_id =&gt; &quot;1&quot;}
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>generators/rspec_nested_scaffold/templates/routing_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,17 @@
-require File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_depth %&gt;/../../spec_helper')
 
 describe &quot;/&lt;%= table_name %&gt;/show.&lt;%= default_file_extension %&gt;&quot; do
   include &lt;%= controller_class_name %&gt;Helper
   
   before(:each) do
-    @&lt;%= file_name %&gt; = mock_model(&lt;%= class_name %&gt;)
-    @&lt;%= nesting_owner %&gt; = mock_model(&lt;%= nesting_owner_class %&gt;)
-&lt;% for attribute in attributes -%&gt;
-    @&lt;%= file_name %&gt;.stub!(:&lt;%= attribute.name %&gt;).and_return(&lt;%= attribute.default_value %&gt;)
+    assigns[:&lt;%= nesting_owner %&gt;] = stub_model(&lt;%= nesting_owner_class %&gt;)
+    assigns[:&lt;%= file_name %&gt;] = @&lt;%= file_name %&gt; = stub_model(&lt;%= class_name %&gt;&lt;%= attributes.empty? ? ')' : ',' %&gt;
+&lt;% attributes.each_with_index do |attribute, attribute_index| -%&gt;&lt;% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%&gt;
+      :&lt;%= attribute.name %&gt; =&gt; &lt;%= attribute.default_value %&gt;&lt;%= attribute_index == attributes.length - 1 ? '' : ','%&gt;
+&lt;% end -%&gt;&lt;% end -%&gt;
+&lt;% if !attributes.empty? -%&gt;
+    )
 &lt;% end -%&gt;
-    assigns[:&lt;%= nesting_owner %&gt;] = @&lt;%= nesting_owner %&gt;    
-    assigns[:&lt;%= file_name %&gt;] = @&lt;%= file_name %&gt;
   end
 
   it &quot;should render attributes in &lt;p&gt;&quot; do</diff>
      <filename>generators/rspec_nested_scaffold/templates/show_erb_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
 &lt;h1&gt;Editing &lt;%= singular_name %&gt;&lt;/h1&gt;
 
-&lt;%%= error_messages_for :&lt;%= singular_name %&gt; %&gt;
+&lt;%% form_for([@&lt;%= nesting_owner %&gt;, @&lt;%= singular_name %&gt;]) do |f| %&gt;
+  &lt;%%= f.error_messages %&gt;
 
-&lt;%% form_for(:&lt;%= singular_name %&gt;, @&lt;%= singular_name %&gt;, :url =&gt; &lt;%= nesting_owner %&gt;_&lt;%= singular_name %&gt;_path(@&lt;%= nesting_owner %&gt;, @&lt;%= singular_name %&gt;), :html =&gt; {:method =&gt; :put}) do |f| %&gt;
 &lt;% for attribute in attributes -%&gt;
   &lt;p&gt;
-		&lt;%%= f.label :&lt;%= attribute.name %&gt; %&gt;&lt;br /&gt;
+    &lt;%%= f.label :&lt;%= attribute.name %&gt; %&gt;&lt;br /&gt;
     &lt;%%= f.&lt;%= attribute.field_type %&gt; :&lt;%= attribute.name %&gt; %&gt;
   &lt;/p&gt;
 &lt;% end -%&gt;
@@ -14,5 +14,5 @@
   &lt;/p&gt;
 &lt;%% end %&gt;
 
-&lt;%%= link_to 'Show', &lt;%= nesting_owner %&gt;_&lt;%= singular_name %&gt;_path(@&lt;%= nesting_owner %&gt;, @&lt;%= singular_name %&gt;) %&gt; |
+&lt;%%= link_to 'Show', [@&lt;%= nesting_owner %&gt;, @&lt;%= singular_name %&gt;] %&gt; |
 &lt;%%= link_to 'Back', &lt;%= nesting_owner %&gt;_&lt;%= plural_name %&gt;_path(@&lt;%= nesting_owner %&gt;) %&gt;</diff>
      <filename>generators/rspec_nested_scaffold/templates/view_edit.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -12,9 +12,9 @@
 &lt;% for attribute in attributes -%&gt;
     &lt;td&gt;&lt;%%=h &lt;%= singular_name %&gt;.&lt;%= attribute.name %&gt; %&gt;&lt;/td&gt;
 &lt;% end -%&gt;
-    &lt;td&gt;&lt;%%= link_to 'Show', &lt;%= nesting_owner %&gt;_&lt;%= singular_name %&gt;_path(@&lt;%= nesting_owner %&gt;, &lt;%= singular_name %&gt;) %&gt;&lt;/td&gt;
+    &lt;td&gt;&lt;%%= link_to 'Show', [@&lt;%= nesting_owner %&gt;, &lt;%= singular_name %&gt;] %&gt;&lt;/td&gt;
     &lt;td&gt;&lt;%%= link_to 'Edit', edit_&lt;%= nesting_owner %&gt;_&lt;%= singular_name %&gt;_path(@&lt;%= nesting_owner %&gt;, &lt;%= singular_name %&gt;) %&gt;&lt;/td&gt;
-    &lt;td&gt;&lt;%%= link_to 'Destroy', &lt;%= nesting_owner %&gt;_&lt;%= singular_name %&gt;_path(@&lt;%= nesting_owner %&gt;, &lt;%= singular_name %&gt;), :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt;
+    &lt;td&gt;&lt;%%= link_to 'Destroy', [@&lt;%= nesting_owner %&gt;, &lt;%= singular_name %&gt;], :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt;&lt;/td&gt;
   &lt;/tr&gt;
 &lt;%% end %&gt;
 &lt;/table&gt;</diff>
      <filename>generators/rspec_nested_scaffold/templates/view_index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
 &lt;h1&gt;New &lt;%= singular_name %&gt;&lt;/h1&gt;
 
-&lt;%%= error_messages_for :&lt;%= singular_name %&gt; %&gt;
+&lt;%% form_for([@&lt;%= nesting_owner %&gt;, @&lt;%= singular_name %&gt;]) do |f| %&gt;
+  &lt;%%= f.error_messages %&gt;
 
-&lt;%% form_for(:&lt;%= singular_name %&gt;, @&lt;%= singular_name %&gt;, :url =&gt; &lt;%= nesting_owner %&gt;_&lt;%= plural_name %&gt;_path(@&lt;%= nesting_owner %&gt;)) do |f| %&gt;
 &lt;% for attribute in attributes -%&gt;
   &lt;p&gt;
-		&lt;%%= f.label :&lt;%= attribute.name %&gt; %&gt;&lt;br /&gt;
+    &lt;%%= f.label :&lt;%= attribute.name %&gt; %&gt;&lt;br /&gt;
     &lt;%%= f.&lt;%= attribute.field_type %&gt; :&lt;%= attribute.name %&gt; %&gt;
   &lt;/p&gt;
 &lt;% end -%&gt;
@@ -14,4 +14,4 @@
   &lt;/p&gt;
 &lt;%% end %&gt;
 
-&lt;%%= link_to 'Back', &lt;%= nesting_owner %&gt;_&lt;%= plural_name %&gt;_path(@&lt;%= nesting_owner %&gt;) %&gt;
\ No newline at end of file
+&lt;%%= link_to 'Back', &lt;%= nesting_owner %&gt;_&lt;%= plural_name %&gt;_path(@&lt;%= nesting_owner %&gt;) %&gt;</diff>
      <filename>generators/rspec_nested_scaffold/templates/view_new.html.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cf8f68533db4755653e099ac54a4964edaf4f4bb</id>
    </parent>
  </parents>
  <author>
    <name>Paul Horsfall</name>
    <email>horsfallp@gmail.com</email>
  </author>
  <url>http://github.com/phorsfall/rspec_on_rails_nested_scaffold/commit/47346461a246a366d723068b90d34bedd84a8267</url>
  <id>47346461a246a366d723068b90d34bedd84a8267</id>
  <committed-date>2008-10-07T07:47:36-07:00</committed-date>
  <authored-date>2008-10-07T07:47:36-07:00</authored-date>
  <message>Updated the view and spec templates with the latest from Rails and Rspec respectively.</message>
  <tree>a822919501ba62cee28e450ecb8e29f644ac86f4</tree>
  <committer>
    <name>Paul Horsfall</name>
    <email>horsfallp@gmail.com</email>
  </committer>
</commit>
