In Rails, how do you functional test a Javascript response format?

前端 未结 9 937
攒了一身酷
攒了一身酷 2021-01-31 15:41

If your controller action looks like this:

respond_to do |format|
  format.html { raise \'Unsupported\' }
  format.js # index.js.erb
end

and yo

9条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 16:44

    Set the accepted content type to the type you want:

    @request.accept = "text/javascript"
    

    Combine this with your get :index test and it will make the appropriate call to the controller.

提交回复
热议问题