Description
Problem
Running a single system test takes about 50 seconds on a project with lots of SASS files. I've investigated Sprockets and found out that SASS files are processed each time a test runs, and Sprockets cache isn't used. And it is not used, because of a random cache key in SassCompressor
.
SassCompressor is monkey patched by sassc-rails and uses a random #cache_key
:
sassc-rails/lib/sassc/rails/compressor.rb
Line 14 in bf66ead
Possible solution
Sprockets uses the following cache key:
@cache_key = "#{self.class.name}:#{Autoload::Sass::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
https://github.com/rails/sprockets/blob/386ab2ba215f828602b6e6bfee9bfc95dc23d574/lib/sprockets/sass_compressor.rb#L46
By using the Sprockets @cache_key
code, I was able to make the test 2x faster (50 -> 25 seconds).
Would it be possible to use a cache key that doesn't change on each run, when no other things have changed?