如何使用 Cucumber 测试 DelayedJob?
我们使用 DelayedJob 来运行一些长时间运行的进程,并希望使用 Cucumber/Webrat 进行测试。
目前,我们在 Ruby 线程中调用 Delayed::Job.work_off 来在后台完成工作,但正在寻找更强大的解决方案,
最好的方法是什么?
谢谢。
We use DelayedJob to run some of our long running processes and would like to test with Cucumber/Webrat.
Currently, we are calling Delayed::Job.work_off in a Ruby thread to get work done in the background, but are looking for a more robust solution
What is the best approach for this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现 Delayed:Job.work_off 方法的主要问题是,您在 Cucumber 场景中明确了属于系统内部的内容。混合这两个问题违背了功能测试的精神:
另一个问题是,您在 Cucumber 场景中填充了重复步骤,以便在需要时分派作业。
我目前使用的方法是在黄瓜场景下在后台启动delayed_job正在执行。您可以检查我在该链接中使用的黄瓜钩子。
The main problem I see with the
Delayed:Job.work_off
approach is that you are making explicit in your Cucumber scenarios something that belongs to the internals of your system. Mixing both concerns is against the spirit of functional testing:Another problem is that you populate your Cucumber scenarios with repetitive steps for dispatching jobs when needed.
The approach I am currently using is launching delayed_job in the background while cucumber scenarios are being executed. You can check the Cucumber hooks I am using in that link.