From d4b14f20361f161414f8f91063efe2fce5937f57 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 26 Mar 2012 11:59:37 -0400 Subject: [PATCH] make sure eventmachine also gets shut down --- lib/flowerbox.rb | 1 + lib/flowerbox/configuration.rb | 2 +- lib/flowerbox/runner/base.rb | 1 + lib/flowerbox/server.rb | 11 +++++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/flowerbox.rb b/lib/flowerbox.rb index fca8b44..6813448 100644 --- a/lib/flowerbox.rb +++ b/lib/flowerbox.rb @@ -27,6 +27,7 @@ module Flowerbox class << self attr_writer :quiet + attr_accessor :server def reset! @configuration = nil diff --git a/lib/flowerbox/configuration.rb b/lib/flowerbox/configuration.rb index 5dd9b25..d1f56e4 100644 --- a/lib/flowerbox/configuration.rb +++ b/lib/flowerbox/configuration.rb @@ -5,7 +5,7 @@ module Flowerbox attr_writer :reporters, :backtrace_filter attr_accessor :port - attr_accessor :test_environment, :runner_environment, :bare_coffeescript, :server + attr_accessor :test_environment, :runner_environment, :bare_coffeescript def spec_patterns @spec_patterns ||= [] diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index 37809de..efde11e 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -140,6 +140,7 @@ module Flowerbox require 'flowerbox/rack' if Flowerbox.server + Flowerbox.server.runner = self Flowerbox.server.app.runner = self Flowerbox.server.app.sprockets = sprockets return Flowerbox.server diff --git a/lib/flowerbox/server.rb b/lib/flowerbox/server.rb index 3bf7475..de4ef8f 100644 --- a/lib/flowerbox/server.rb +++ b/lib/flowerbox/server.rb @@ -10,7 +10,7 @@ module Flowerbox class Server attr_reader :options - attr_reader :runner + attr_accessor :runner class MissingRackApp < StandardError ; end class ServerDiedError < StandardError ; end @@ -83,6 +83,8 @@ module Flowerbox def stop if @server_thread @server_thread[:server].stop rescue nil + EventMachine.stop_event_loop + @server_thread.kill wait_for_server_to_stop end @@ -93,7 +95,12 @@ module Flowerbox end def port - return @port if @port ||= options[:port] + return @port if @port + + if options[:port] + @port = options[:port] + return @port + end attempts = 20