RSPEC:如何测试具有Sidekiq_option lock的工人::直至dex_exected Isn' t in两次?
我想用rspec和gem 。
假设我有这项工作:
class TestJob < ApplicationWorker
include Sidekiq::Worker
sidekiq_options queue: 'test_queue', lock: :until_executed
def perform
puts "Hello World !"
end
end
我希望能够通过以下测试进行测试:
it "doesn't enqueue a job to send an email to the rider" do
TestJob.perform_async
TestJob.perform_async
expect(TestJob.jobs.size).to eq(1)
end
这将使我确定我的工作永远不会排队不止一次。
你怎么做?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论