컨트롤러를 테스트해야하는 rspec 테스트가 있습니다. facebook_profile.user_q1 유효한 결과를 얻을 수 있도록 @rspec 컨트롤러 테스트에서 변수 할당
it "renders the #show view" do
get :show, id: FactoryGirl.create(:quiz)
@facebook_profile = FactoryGirl.create(:facebook_profile)
response.should render_template :show
end
facebook_profile 객체는 user_q1 열을 갖는다.
@user_q1 = @facebook_profile.user_q1
이 수동 테스트에서 잘 작동하지만 RSpec에, 나는이 결과를 얻을 : 내가 문제가 첫 번째 줄에, 여기에 의심
undefined method `user_q1' for nil:NilClass
을 내 퀴즈 컨트롤러에서
@facebook_profile = FacebookProfile.find_by_facebook_id(session[:facebook_profile_id])
나는 내 세션 컨트롤러에 변수가있다. 어떤 모델의 칼럼) 내가 facebook_profile_id라고 부른다. 그런 다음 퀴즈 컨트롤러에서 위의 코드 줄에서이 변수를 호출합니다. 내 사양은 facebook_profile_id를 알지 못하기 때문에 @facebook_profile을 정의 할 수 없다고 생각합니다. 외관상으로는 "@facebook_profile = FactoryGirl"을 정의하는 것만으로는 작동하지 않습니다.