Skip to Content

RSpec - Disable 'process' carrierwave to improve RSpec performance

Posted on


Our CI takes ~30 mins to run and we need to find some ways to improve our testing run time.

After using rspec -profile options to detect top 100 slowest test cases, we try to deep down and find the reasons why this test is slow.

One of those reasons is: We still use carrierwave processing image feature in test environment. After an image is uploaded, we process resize_to_fit this image to another size.

So each time we run FactoryBot.create :user, :with_image, it take time to upload and resize the image.


Disable processing image in Test environment.

# config/initializers/carrierwave.rb

if Rails.env.test? or Rails.env.cucumber?
  CarrierWave.configure do |config| = :file
    config.enable_processing = false

If you need to test your processing, you should test it in isolation, and enable processing only for those tests that need it.


comments powered by Disqus