分享 终于决定还是放弃 rspec 的 transaction 了

fsword · 2012年02月24日 · 1936 次阅读

反复遇到不能正确 cleanup 的问题,今天看到这篇 blog ( http://blog.angelbob.com/posts/316-RSpec-don-t-use-transactional-fixtures---published-rails ),虽然有点旧,但是确实就是我的现状,不明白 rspec 为什么改不好,还是决定用 database_cleaner 了。

博客主要内容摘抄

This will fail. It will fail because that let statement lives outside of the transactions, so it doesn't get cleaned up, and that old stale database object sits around polluting the database.

That means let() blocks, subject() blocks, it() blocks, its() blocks and specify() blocks are all exempt from cleanup. 
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号