m new to rails
I am using RSpec gem for testing
This is my controller
class QuestionsController < ApplicationController
before_action :require_user, except: %i[show index]
before_action :authorize_user, only: %i[edit update destroy]
def index
@questions = Question.all
end
def show
@answers = Answer.where('question_id = :question_id ', { question_id: params[:id] })
@count = Answer.where('question_id = :question_id ', { question_id: params[:id] }).count
$count_global = @count
session[:question_id] = params[:id]
@questions = Question.all
end
def new
@question = Question.new
end
def edit; end
def create
@question = Question.new(question_params)
@question.user_id *strong text*= current_user.id
@question.save
redirect_to root_path
end
end
This is spec/requests/question_spec.rb
describe "GET /new" do
it "renders a successful response" do
get new_question_url
expect(response).to be_successful
end
end
The test is not passing The error is
Failure/Error: expect(response).to be_successful
expected `#<ActionDispatch::TestResponse:0x0000558594f082e0 @mon_data=#<Monitor:0x0000558594f08290>, @mon_data_..., @method=nil, @request_method=nil, @remote_ip=nil, @original_fullpath=nil, @fullpath=nil, @ip=nil>>.successful?` to be truthy, got false
Could anyone help regarding this issue