title: Test private method of controller with rspec
body: <p>I have</p>
  
  <pre><code>class Api::V1::BaseController &lt; ApplicationController
     before_filter :authenticate!
  
    private
    def authenticate!
      session_token = request.env["HTTP_SESSIONTOKEN"]
      @current_user = User.where(session_token: session_token).first unless session_token.blank?
      unless @current_user
        return render_json({message: "ERROR: Invalid Session"})
      end
    end
  
    def current_user
      @current_user
    end 
  end
  </code></pre>
  
  <p>I am testing session_controller which inherits base_controller </p>
  
  <pre><code>before do 
      post :create, {email: "raj@gmail.com", user_name: "raj",password: "raj"}
      body = JSON.parse(response.body)
      @session_token = body["session_token"]
  end
  
     describe "PUT #edit_email" do
      context "if new email already exist" do
        it "should return with a error message" do
          put :edit_email, {email: "raj@gmail.com", new_email: "ravi@gmail.com", password: "raj"}
          body = JSON.parse(response.body)
          expect(body["message"]).to eq("email already exist")
        end
      end
    end
  </code></pre>
  
  <p>I am new to rspec and here I am confused about calling private authenticate method with session_token.
  How to call private method of controller and pass header.Thanks in advance.</p>