用rSpec测试delay_job链的最佳方法是什么? [英] What's the best way to test delayed_job chains with rSpec?

查看:88
本文介绍了用rSpec测试delay_job链的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,当我在代码中使用如下所示的延迟方法时:

Currently when I have a delayed method in my code like the following:

CommentMailer.delay.deliver_comments(@comment, true)

我在规格中写了这样的东西:

I write something like this in my spec:

dj = mock("DelayProxy")
CommentMailer.should_receive(:delay).and_return(dj)
dj.should_receive(:deliver_comments).with(comment, true)

是否有更好的方法来处理此方法和/或类似的链接方法

Is there a better way to handle this and/or chained methods like that in rSpec in general?

推荐答案

下面是有关rSpec中链接方法的一些讨论,我发现这很有帮助:

Here are some discussions about chaining methods in rSpec that I found helpful:

使用Rspec对链式方法进行存根

http:// groups。 google.com/group/rspec/browse_thread/thread/6b8394836d2390b0#

这篇关于用rSpec测试delay_job链的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆