How do you test the params hash in a Rails test?

笑着哭i 提交于 2019-12-05 05:13:11
Jim Deville

http://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers gives some of this information.

In this case, params is attached to the @request or @response object (depending on what HTTP method you are testing), so you can refer to it as @request.params[:recipient_id].

For redirect: assert_redirected_to post_path(assigns(:post)) will assert that you are redirected to the proper path for a given model. The assigns method should have the instance variables you are setting inside of the controller to pass to the view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!