Skip to content

Instantly share code, notes, and snippets.

@takai
Created November 21, 2012 10:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takai/4124293 to your computer and use it in GitHub Desktop.
Save takai/4124293 to your computer and use it in GitHub Desktop.
require 'foreman/engine/cli'
procfile = File.expand_path('../../Procfile', __FILE__)
envfile = File.expand_path('../../.env', __FILE__)
foreman = Foreman::Engine::CLI.new
foreman.load_procfile(procfile)
foreman.load_env(envfile) if File.exist? envfile
RSpec.configure do |config|
config.before(:all) do
Thread.new do
foreman.startup
foreman.__send__ :spawn_processes
foreman.__send__ :watch_for_output
end
sleep 0.1 # wait for server to start
end
config.after(:all) do
running = foreman.instance_variable_get(:@running)
running.keys.each do |pid|
Process.kill 'TERM', pid
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment