|# may also need to configure, either here|
|Rails.application.config.action_view.cache_template_loading = true|
|# or in config/environments/test.rb:|
|# config.action_view.cache_template_loading = true|
|# ensure ActionView::Digestor is already autoloaded before patching it|
|# stop the PerExecutionDigestCacheExpiry actually clearing the cache|
|# not clearing cache now|
|# ensure view context is cleared once before each test run|
|RSpec.configure do |config||
After the upgrade of a rails app from 4.2 to 5.0.6, the performance of features tests went slower by 50-100% and overall test suite went from 11min +/-1min to 17min +/-1min (with parallelism). The app had some STI and abstract model inheritance and plenty of views, and a preponderance of feature tests.
Collected stats on speeds of the suite for 4.2 and 5.0.6 and compared significant changes in different specs and determined that the features were the ones with the significant change. Used stackprof (https://gist.github.com/leonelgalan/a613c1d8e293f3219327 with wall-time sampling) on a small set of feature specs and found that the top three items on the list were:
the second two were nowhere in the list in 4.2.
Searching on find_template_paths found some suggestions like rails/rails#20752 (comment) (didn't make an impact). But then reading https://github.com/rails/rails/blob/v5.0.6/actionview/lib/action_view/digestor.rb#L9 and https://github.com/rails/rails/blob/v5.0.6/actionview/lib/action_view/railtie.rb#L42 got me to creating this to work around the problem.
By adding the spec support above both the sampled feature tests and the overall suite became the same as it was on the 4.2 branch.
However this is fixed in rails 5.1: rails/rails@2380354#diff-5630af1610e29418fbdfd318b8f68eb3 provided either: