【发布时间】:2018-02-26 00:12:51
【问题描述】:
我目前正在使用 Rspec 请求测试嵌套路由的发布请求。
它是这样设置的:
describe 'POST /url_contents' do
let!(:role) { create(:role, name: "admin") }
let(:valid_attributes) {
{
jwt: "SAMPLE",
role: role
}
}
context 'when the url is valid' do
before { post "/#{role.name}/1", params: valid_attributes }
it 'returns a status code of 201' do
expect(response).to have_http_status(201)
end
end
end
我正在点击我的控制器,但是当我检查参数时,我得到了一个嵌套参数:
:params => { :params => { :jwt => "SAMPLE", :role => #<Role:0x0055959d32a888>" }, "controller"=> "auth"... }
如何让参数指向我的控制器的 :jwt?
【问题讨论】:
标签: rails-activerecord rspec-rails nested-routes