title: Undefined local variable or method params in Rspec
body: <p>Hi I am implementing a method to delete a user account in my web application. My controller:</p>
  
  <pre><code>class UsersController &lt; ApplicationController
  
      before_filter :set_current_user
  
      def user_params
          params.require(:user).permit(:user_id, :first_name, :last_name, :email, :password, :password_confirmation)
      end
  
      def delete_account
          @user = User.find_by_id(params[:id])
          if @user.present?
              @user.destroy
          flash[:notice] = "User Account Deleted."
          end
          redirect_to root_path
      end
  
      def destroy
          User.delete(:user_id)
          redirect_to root_path
      end
  end
  </code></pre>
  
  <p>My rspec:</p>
  
  <pre><code>require 'spec_helper'
  require 'rails_helper'
  require'factory_girl'
  
  describe UsersController do
     describe "delete account" do
  
          before :each do
              @fake_results = FactoryGirl.create(:user)
          end
  
          it "should call the model method that find the user" do
              expect(User).to receive(:find).with(params[:id]).and_return (@fake_results)
          end
  
          it "should destroy the user account from the database" do
              expect{delete :destroy, id: @fake_results}.to change(User, :count).by(-1)
          end
  
          it "should redirect_to the home page" do
             expect(response).to render_template(:home)
          end
  
     end 
  end
  </code></pre>
  
  <ol>
  <li><p>The first error is </p>
  
  <pre><code>Failure/Error: expect(User).to receive(:find).with(params[:id]).and_return (@fake_results)
  
  NameError:undefined local variable or method `params' for #&lt;RSpec::ExampleGroups::UsersController::DeleteAccount:0x00000007032e18&gt;
  </code></pre></li>
  </ol>
  
  <p>I know what this error means but I don't know how to correct it. How can I pass the user id from the controller to rspec?</p>
  
  <ol start="2">
  <li><p>The second error is:</p>
  
  <pre><code>Failure/Error: expect(response).to render_template(:home)
  expecting &lt;"home"&gt; but rendering with &lt;[]&gt;
  </code></pre></li>
  </ol>
  
  <p>I think there is something wrong with my controller method. It should redirect to the home page but it doesn't.</p>