如何测试创建实例的类方法?
我有这样一个类:
class BaseService
def self.call(*args)
new(*args).call
end
end
我需要测试 #self.call 使用给定参数创建新实例并向其发送 :call 消息。 怎么可能呢? 提前致谢!
I have such a class:
class BaseService
def self.call(*args)
new(*args).call
end
end
I need to test that #self.call creates new instance with given arguments and sends it :call message.
How is it possible?
Thanx in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会执行以下操作
另一个(也许更好)选项可能是测试
BaseService.call(*arguments)
是否具有预期的输出或副作用。但是因为您没有编写new(*args).call
实际执行的操作,所以我无法对此提出建议。I would do the following
Another (and perhaps better) option might be to test that
BaseService.call(*arguments)
has the expected output or side-effects. But because you didn't write whatnew(*args).call
actually does I cannot make a suggestion for that.