mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Right now and for some time the engines are not independent of the main_app. We should aim for that but it will naturally take a while to disentangle the code
48 lines
1.3 KiB
Ruby
48 lines
1.3 KiB
Ruby
namespace :ofn do
|
|
namespace :specs do
|
|
namespace :engines do
|
|
def detect_engine_paths
|
|
Pathname("engines/").children.select(&:directory?)
|
|
end
|
|
|
|
def engine_name_for_engine(engine_path)
|
|
engine_path.basename.to_path
|
|
end
|
|
|
|
def execute_rspec_for_engine(engine_path)
|
|
system "DISABLE_KNAPSACK=true bundle exec rspec #{engine_path.expand_path}/spec"
|
|
end
|
|
|
|
engine_paths = detect_engine_paths
|
|
|
|
engine_paths.each do |engine_path|
|
|
engine_name = engine_name_for_engine(engine_path)
|
|
|
|
namespace engine_name do
|
|
desc "Run RSpec tests for engine \"#{engine_name}\""
|
|
task :rspec do
|
|
success = execute_rspec_for_engine(engine_path)
|
|
abort "Failure when running tests for engine \"#{engine_name}\"" unless success
|
|
end
|
|
end
|
|
end
|
|
|
|
namespace :all do
|
|
desc "Run RSpec tests for all engines"
|
|
task :rspec do
|
|
success = true
|
|
|
|
engine_paths.each do |engine_path|
|
|
success = !!execute_rspec_for_engine(engine_path) && success
|
|
end
|
|
|
|
abort "Failure encountered when running tests for engines" unless success
|
|
end
|
|
end
|
|
|
|
desc "Alias for openfoodnetwork:specs:engines:all:rspec"
|
|
task rspec: "all:rspec"
|
|
end
|
|
end
|
|
end
|