Rspec Controller tests, passing JSON params

六月ゝ 毕业季﹏ 提交于 2019-12-04 06:32:48
thelastinuit
post "/models/#{@model.id}",
        params: {
            some_field: "1234",
        },
        as: :json

You can pass header in your RSpec file.

header "Content-Type", "application/json"
post :something

And you can pass params like this :

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