aks*_*aks 5 ruby rspec ruby-on-rails
我对如何使用新expect语法模拟类方法感到困惑.这有效:
Facebook
.should_receive(:profile)
.with("token")
.and_return({"name" => "Hello", "id" => "14314141", "email" => "hello@me.com"})
Run Code Online (Sandbox Code Playgroud)
这不是:
facebook = double("Facebook")
allow(facebook).to receive(:profile).with("token").and_return({"name" => "Hello", "id" => "14314141", "email" => "hello@me.com"})
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这里有什么问题?
这是您想要做的(不需要double):
allow(Facebook)
.to receive(:profile)
.with("token")
.and_return({"name" => "Hello", "id" => "14314141", "email" => "hello@me.com"})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1165 次 |
| 最近记录: |