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

前端 未结 9 1034
攒了一身酷
攒了一身酷 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:41

    Pass in a :format with your normal params to trigger a response in that format.

    get :index, :format => 'js'
    

    No need to mess with your request headers.

提交回复
热议问题