2012-05-16 7 views
0

이 코드했습니다 :루비 테스트

def test_create 
    assert_difference('Comment.count') do 
     post :create, :comment => {:comment => 'Comment'} 
     assert_not_nil assigns(:comment) 
     assert_equal assigns(:comment).comment, "Comment" 
     assert_equal assigns(:comment).valid?, true 
    end 
    assert_response :redirect 
    assert_redirected_to article_path(assigns(:comment)) 
    assert_equal flash[:notice], 'Comment was successfully created.' 
    end 

을 그리고 테스트하려고하지만, 반환 :

test_create(CommentsControllerTest) [test/functional/comments_controller_test.rb:5]: 
<nil> expected to not be nil. 

이 코드에 어떤 문제가 있습니까? 제발 도와주세요. 나는 레일즈에있는 초보자입니다.

답변

0

"기대하지 말아야 할 것"이라고 말합니다. 따라서 주석 변수를 확인하는 assert_not_nil 줄에서 불평하고 있습니다.

해당 변수에 문제가 있습니다. 어쩌면 존재하지 않을 수도 있습니다.

관련 문제