如何在线程或子进程中运行和停止delayed_jobs工作线程以进行测试
我希望能够执行一些需要工作人员运行的测试。
为了实现这一点,创建了这个测试辅助方法:
def with_delayed_jobs
t=Thread.new {Delayed::Worker.new.start}
sleep(5)
yield
t.exit
end
所以我可以在我的测试中编写
with_delayed_jobs {
___test_content___
}
不幸的是,工作人员似乎不以这种方式运行。也许我可以通过流程来做到这一点。有人知道如何实现这一目标吗?
I would like to be able to perform some tests that require a worker to be running.
In order to accomplish this created this test helper method:
def with_delayed_jobs
t=Thread.new {Delayed::Worker.new.start}
sleep(5)
yield
t.exit
end
So I can write in my tests
with_delayed_jobs {
___test_content___
}
Unfortunately, the worker doesn't seem to run this way. Maybe I can do it with processes. Does anybody have an idea on how to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下命令运行作业表中当前的作业:
文档在这里,尽管它们很稀疏。
You can run the jobs that are currently in your jobs table with this:
Docs are here, although they are sparse.