mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
The KnapsackPro queue mode can't predict which specs it will run. So we need to check on each file (top-level describe block) which type of spec it is and if we need to compile assets for it. Old versions of KnapsackPro would execute the `before(:suite)` hooks on every batch, but now it's only run once. With this change, we do the same as before.
19 lines
602 B
Ruby
19 lines
602 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.configure do |config|
|
|
config.before(:all) do
|
|
# We can use webpack-dev-server for tests, too!
|
|
# Useful if you working on a frontend code fixes and want to verify them via system tests.
|
|
next if Webpacker.dev_server.running?
|
|
|
|
specs_needing_assets = %i[controller feature mailer request system view]
|
|
examples = RSpec.world.filtered_examples.values.flatten
|
|
types = examples.map(&:metadata).pluck(:type).uniq
|
|
|
|
if types.intersect?(specs_needing_assets)
|
|
$stdout.puts "\n Precompiling assets.\n"
|
|
Webpacker.compile
|
|
end
|
|
end
|
|
end
|