2017-12-24 28 views
1

레일 5와 minutest를 사용하여 컨트롤러에 대한 테스트를 작성하려고합니다. 이 시험은 내가 테스트를 실행할 때, 나는이 오류가 발생하지만내 테스트 프레임 워크에서 내 경로 파일에 정의 된 URL을 찾을 수없는 이유는 무엇입니까?

# issues_controller_test.rb 
class IssuesControllerTest < ActionDispatch::IntegrationTest 

    include Devise::Test::IntegrationHelpers 

    test "logged in should get issues page" do 
    sign_in users(:one) 
    test_stop_id = 1 
    test_line_id = 1 
    get new_issue, :stop_id => test_stop_id, :line_id => test_line_id 
    assert_equal test_stop_id, @issue.stop_id 
    assert_equal test_line_id, @issue.line_id 
    assert_response :success 
    end 
end 
문제의 방법은 내 레일 노선에 정의 된이 페이지에 액세스하려고 시도

...

  new_issue GET  /issues/new(.:format)    issues#new 

입니다

# Running: 

.E 

Error: 
IssuesControllerTest#test_logged_in_should_get_issues_page: 
NameError: undefined local variable or method `new_issue' for #<IssuesControllerTest:0x007f816759b330> 
    test/controllers/issues_controller_test.rb:10:in `block in <class:IssuesControllerTest>' 


bin/rails test test/controllers/issues_controller_test.rb:6 



Finished in 0.103956s, 19.2389 runs/s, 9.6195 assertions/s. 

왜 테스트 프레임 워크는 내 경로 파일에 정의 된 메소드를 찾을 수 없습니까? 방법은 어디에도 정의되지 단지 지역 변수입니다

답변

0

new_issue, new_issue_url와 함께 작업 URL로 지정하려고 :

test 'logged in should get issues page' do 
    sign_in users :one 
    test_stop_id = 1 
    test_line_id = 1 
    get new_issue_url, stop_id: test_stop_id, line_id: test_line_id 
    assert_equal test_stop_id, @issue.stop_id 
    assert_equal test_line_id, @issue.line_id 
    assert_response :success 
end