我对如何使用 new 模拟类方法感到困惑expect
句法。
这有效:
Facebook
.should_receive(:profile)
.with("token")
.and_return({"name" => "Hello", "id" => "14314141", "email" => "[email protected] /cdn-cgi/l/email-protection"})
这不是:
facebook = double("Facebook")
allow(facebook).to receive(:profile).with("token").and_return({"name" => "Hello", "id" => "14314141", "email" => "[email protected] /cdn-cgi/l/email-protection"})
有人可以告诉我这里出了什么问题吗?
这就是你想要做的(不需要double
):
allow(Facebook)
.to receive(:profile)
.with("token")
.and_return({"name" => "Hello", "id" => "14314141", "email" => "[email protected] /cdn-cgi/l/email-protection"})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)