Rails: Removing the cucumber-rails warning when setting cache_classes to false without Spring enabled

Posted . Visible to the public.

We are using Spring in our tests for sequential test execution but not for parallel test execution. And Rails requires you to set the config.cache_classes = false if you are using Spring in tests.

With our setup, this would raise the following error in cucumber-rails Show archive.org snapshot for parallel test executions due to some legacy database cleaner issue.

WARNING: You have set Rails' config.cache_classes to false
    (Spring needs cache_classes set to false). This is known to cause problems
    with database transactions. Set config.cache_classes to true if you want to use transactions.

Fix

You need to upgrade to cucumber-rails >= 2.1.0 and adjust the config.cache_classes in config/environments/test.rb like below:

config.cache_classes = !defined?(Spring)
Last edit
Bruno Sedler
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2021-09-20 09:06)