使用 Rspec 测试 Sidekiq 工人 [英] Testing Sidekiq workers using Rspec
本文介绍了使用 Rspec 测试 Sidekiq 工人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 rspec 在 5 分钟内测试以下代码行调用执行"?
How do i test the following line of code invokes 'perform' in 5 mins using rspec?
CustomSidekiqWorker.perform_in(5.minutes, parameter1)
推荐答案
如果您已将 Sidekiq 设置为在运行测试时使用内联处理,如下所示:
If you've set Sidekiq to use inline processing while runnings tests like so:
require 'sidekiq/testing'
Sidekiq::Testing.inline!
那么以下内容应该适用于您的规范:
Then the following should work in your specs:
expect(CustomSideWorker).to receive(:perform_in).with(5.minutes, parameter1)
这篇关于使用 Rspec 测试 Sidekiq 工人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文