max*_*max 2 ruby rspec ruby-on-rails
如何编写期望使用类的任何实例调用的消息期望?我想做这样的事情:
@controller.should_receive(:sign_in_and_redirect).with(kind_of? User)
Run Code Online (Sandbox Code Playgroud)
@controller.should_receive(:sign_in_and_redirect).with(an_instance_of(User))
有关详细信息,请参阅Relish文档的"参数匹配器"部分.我链接到RSpec 2.13文档,但是应该有一个选择框,允许您在需要时更改文档版本.
更新:
在RSpec 3.2文档中,他们说要使用instance_of.