目前我的代码中有一个延迟方法,如下所示:
CommentMailer.delay.deliver_comments(@comment, true)
Run Code Online (Sandbox Code Playgroud)
我在我的规范中写了这样的东西:
dj = mock("DelayProxy")
CommentMailer.should_receive(:delay).and_return(dj)
dj.should_receive(:deliver_comments).with(comment, true)
Run Code Online (Sandbox Code Playgroud)
是否有更好的方法来处理这种和/或链式方法,例如rSpec中的方法?