2012-07-26 5 views
3

minitest로 컨트롤러를 테스트해야합니다. 나는 시도했다 :minitest : 정의되지 않은 메소드`get '

describe 'CommentsController' do 
    it "should get index" do 
    get :index 
    assert_response :success 
    end 
end 

class CommentsControllerTest < MiniTest::Unit::TestCase 
    def test_should_get_index 
    get :index 
    assert_response :success 
    end 
end 

하지만 내가 "정의되지 않은 메서드`얻을"오류

답변

5

당신은 minitest-rails 보석을 추가해야합니다 가지고 문서에 설명 된 단계에 따라 . 위의 첫 번째 예에서 success` 기대 : 당신이`must_respond_with를 사용할 수 있다고 생각

require "minitest_helper" 

class CommentsControllerTest < MiniTest::Rails::ActionController::TestCase 
    test "should get index" do 
    get :index 
    assert_response :success 
    end 
end 
+0

을 : 같이,

require "minitest_helper" describe CommentsController do it "should get index" do get :index assert_response :success end end 

을 또는 : 그런 다음 테스트는 다음과 같아야합니다. – partydrone

+0

사용중인 minitest-rails 버전에 따라 yes입니다. – blowmage

관련 문제