In rspec_helper.rb we need to add
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
and in spec_controller.rb file
before (:each) do
@user = FactoryGirl.create(:user)
if using FactroyGirl.
we can also add
in each and every controller where controller is protected. followed by sign_in @user
I hope it help.