Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test:prepare task を利用し、テスト開始前に必要なプロセスを foreman で起動しつつ rake 終了時に掃除する ( Thread が at_exit で自動的に kill されることを利用している )
require 'childprocess'
if (!ENV['CI_ENV'] && ENV['CI_ENV'] != 'false')
namespace :test do
task :prepare do
puts 'foreman start -f Procfile.test'
Thread.new do
begin
ChildProcess.posix_spawn = true
puts "foreman starting ..."
process = ChildProcess.build('foreman', 'start', '-f', 'Procfile.test')
process.leader = true
process.start
process.wait
ensure
puts 'foreman shutting down ...'
process.stop
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment