且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Rails-如何为特定/伪造的http或ajax响应设置特定的响应时间

更新时间:2023-11-20 23:45:43

如果您真的希望它只等待超时,我相信您可以使用and_return的Proc版本,并且只要您希望请求接受就可以睡觉

If you really want it to just wait for the timeout I believe you can use the Proc version of and_return and sleep for as long as you want the request to take

proxy.stub("http://127.0.0.1:59533/deals/dealname/ajaxrequest").and_return(
  Proc.new { |params, headers, body|
    sleep 11
    {code: 200}
  } )

而且-而不是wait_for_ajax只是传递您希望元素在调用内出现的时间

also - rather than wait_for_ajax just pass the amount of time you expect the element to take to appear to the within call

within('ul.messenger', wait: 11) do ...