Is DatabaseCleaner still necessary with Rails system specs?

一个人想着一个人 提交于 2019-12-02 19:05:31

You do not need the DatabaseCleaner gem. Here's a quick summary of steps you need:

  1. Remove capybara-selenium gem and database_cleaner gem
  2. Add selenium-webdriver gem
  3. Make sure you are using Rails 5.1.5 or later. Earlier versions of Rails 5.1 had a defect in ActionDispatch::SystemTesting::Server that caused problems (fixed here).
  4. In your rails_helper file, set config.use_transactional_fixtures = true
  5. If you are using Devise for auth, in your rails_helper file, set config.include Devise::Test::IntegrationHelpers, type: :system
  6. Set up a basic_configure file as per this post by Noel Rappin.
  7. Replace RSpec.feature throughout with RSpec.describe.

See this commit for more details as to how I managed the switch. It was a hassle, but hopefully easier now that 5.1.5 has fixed the ActionDispatch::SystemTesting::Server issue (I had to monkey patch the file in 5.1.4, but you won't have to now).

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