反复遇到不能正确cleanup的问题,今天看到这篇blog,虽然有点旧,但是确实就是我的现状,不明白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.
使用以后的感受,果然象传说的一样,用例执行速度确实慢了很多,不过还能忍受
本文讨论了在测试过程中遇到的cleanup问题,并介绍了使用database_cleaner解决该问题的经验。文章提到,尽管这种方法减缓了测试速度,但仍然可以接受。
1013

被折叠的 条评论
为什么被折叠?



