Rails Minitest 테스트 오류

조회수 1397회

레일즈에서 미니테스트로 테스트를 짜고 돌리는데 아래와 같은 오류가 나왔습니다.

Minitest::UnexpectedError: AbstractController::DoubleRenderError: Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".

위의 에러는 어떻게 해결하고 테스트해야하나요?

제가 테스트 하고 싶었던것은 아래와 같은 단순한 conteroller test였습니다.

class UsersControllerTest < ActionController::TestCase
test '자기소개를 가져올 수 있다.' do
    get :info, format: :js
    assert_response :success
  end
end
실제 컨트롤러
class UsersController < ApplicationController

def info

end
end

테스트가 아닌 실제 뷰에서는

link_to('정보', info_user_url, remote: true)

위와같은 식으로 링크를 넣어줘서 링크를 클릭하면 info.js.coffee 뷰 잘 보여지고 있습니다. 테스트에서만 에러가 나네요.

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)