rspec测试分叉过程

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

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

  1. # Code block
  2. Process.detach(
  3. fork do
  4. sleep(60)
  5. hook_resp = Faraday.post(url, webhook_body, 'Content-Type' => 'application/json')
  6. logger.debug("Pushed to webhook listener, HTTP #{hook_resp.status} received")
  7. end
  8. )
  1. # RSpec test
  2. it 'should sent to receiver' do
  3. expect(Faraday).to receive(:post)
  4. .with('http://web.hook', anything, anything).and_return(double(status: 200))
  5. subject.call_method(params)
  6. end

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

暂无答案!

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

相关问题