我将 rspec 版本从 2 升级到 3。这是我面临的问题之一:
Failures:
1) Slide after .destroy(force: false) visible if .with_deleted
Failure/Error: expect{@slide.destroy(force: false)}.to_not change(Slide.with_deleted, :count).by(1)
NotImplementedError:
`expect { }.not_to change { }.by()` is not supported
# ./spec/models/slide_spec.rb:36:in `block (3 levels) in <top (required)>'
并在 rspec's changelog我可以读到它从未被支持 (oink ?!@#)。同时还有some examples how to use change syntax但没有
not
关键词。所以问题是如何期望没有变化?
最佳答案
幸运的是,我不希望有任何变化(任何),所以我可以省略 by()
部分。它工作得很好!
expect{@slide.destroy(force: false)}.to_not change(Slide.with_deleted, :count)
关于ruby-on-rails - 不支持 not_to change.by(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25267875/