【发布时间】:2011-03-11 08:54:25
【问题描述】:
我有一个这样的构造函数:
class Foo
def initialize(options)
@options = options
initialize_some_other_stuff
end
end
如果实例化一个新的 Foo 对象,想要测试对initialize_some_other_stuff 的调用。
我发现了这个问题rspec: How to stub an instance method called by constructor?,但调用Foo.any_instance(:initialize_some_other_stuff) 的建议解决方案在我的 rspec 版本 (2.5.0) 中不起作用。
谁能帮我测试这个构造函数调用?
【问题讨论】:
标签: ruby constructor mocking rspec