Kon*_*rad 4 scope rspec ruby-on-rails
我在 Rspec 中编写了以下测试:
expect {
...
}.to change( User.where(:profile.exists => true), :count ).by(1)
Run Code Online (Sandbox Code Playgroud)
但此作用域仅执行一次,并且始终是具有相同大小的相同数组。如何让rspec在expect中运行代码之前和之后执行这个范围?
这对于有类似问题的其他人可能有效,也可能无效。原问题中未包含语料库,且未经独立验证。
expect {
# test goes here
}.to change{ User.where(:profile.exists => true).count }.by(1)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3370 次 |
| 最近记录: |