我在rspec控制器测试中发送AJAX请求,如以下
it 'responds with success' do
xhr :get, :index, delivery_method: :deliver, status: :pending, format: 'js'
expect(response.status).to eq(200)
end
但我不知道如何在Integration
测试中发送相同的请求。
我们可以像
一样简单地发送请求
xhr 'get','[path_to_action]', delivery_method: :deliver, status: :pending, format: 'js'
这里CCD_ 2是rails请求助手方法。