rspec测试分叉过程

rryofs0p  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(178)

我为我的qa团队创建了一个webhook模拟器。为了防止webhook在同步请求完成之前到达,我将发送webhook的代码块分叉为延迟发送60秒。
我很好奇是否可以用rspec在forked进程中测试代码。


# Code block

Process.detach(
  fork do
    sleep(60)
    hook_resp = Faraday.post(url, webhook_body, 'Content-Type' => 'application/json')
    logger.debug("Pushed to webhook listener, HTTP #{hook_resp.status} received")
  end
)

# RSpec test

it 'should sent to receiver' do
  expect(Faraday).to receive(:post)
    .with('http://web.hook', anything, anything).and_return(double(status: 200))        
  subject.call_method(params)
end

显然,我考试不及格。这是可以测试的吗?我真的不在乎webhook接收者的React,只是一场火灾和遗忘。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题