rspec test passes in isolation, but fails when run with other tests

北战南征 提交于 2019-11-30 08:33:27

This usually indicates that your other specs leave some data in the DB that conflicts with later factory calls. I suspect if you look into why the factory create method failed, you'll see a validation for uniqueness fail, maybe on the customer's email.

Turn off transactional fixtures:

# spec_helper.rb
config.use_transactional_fixtures = false

and use database cleaner instead. This blog post might help as well.

RSpec now has a "bisect" feature designed specifically for finding this kind of issue.

Run the RSpec command that's causing the failure with the --bisect flag, and RSpec will automatically identify which combination of specs is causing that failure.

rspec spec/models --bisect
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!