diff --git a/Rakefile b/Rakefile index 7c6aacf..4c774a2 100644 --- a/Rakefile +++ b/Rakefile @@ -3,22 +3,4 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :server do - pid = 0 - Bundler.with_clean_env do - nul = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'nul' : '/dev/null' - pid = spawn "bundle exec puma 'spec/chat_server.ru' 2>#{nul}" - end - - at_exit do - $stderr.puts "Killing pid #{pid}" - Process.kill('KILL', pid) - Process.wait(pid) - end - - sleep 3 -end - -task :spec => :server - task default: :spec diff --git a/spec/chat_server.ru b/spec/chat_server_helper.rb similarity index 79% rename from spec/chat_server.ru rename to spec/chat_server_helper.rb index b47e64d..fff11db 100644 --- a/spec/chat_server.ru +++ b/spec/chat_server_helper.rb @@ -11,4 +11,13 @@ # Run the Chat Sinatra app. require "#{chat_example_path}/chat" -run Chat + +RSpec.configure do |config| + config.around(:all) do |example| + server = Thread.new { Chat.run! } + + example.run + + server.kill + end +end