Read more

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

Emanuel
September 20, 2021Software engineer at makandra GmbH

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.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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)
Posted by Emanuel to makandra dev (2021-09-20 11:06)