diff --git a/contrib/ruby/jasmine_runner.rb b/contrib/ruby/jasmine_runner.rb index b1808f2b..e202aff6 100644 --- a/contrib/ruby/jasmine_runner.rb +++ b/contrib/ruby/jasmine_runner.rb @@ -133,7 +133,12 @@ module Jasmine JsAlert.new ]) - Thin::Server.start('0.0.0.0', port, app) + begin + Thin::Server.start('0.0.0.0', port, app) + rescue RuntimeError => e + raise e unless e.message == 'no acceptor' + raise RuntimeError.new("A server is already running on port #{port}") + end end end diff --git a/contrib/ruby/spec/jasmine_runner_spec.rb b/contrib/ruby/spec/jasmine_runner_spec.rb index 20484ef4..054f3ddf 100644 --- a/contrib/ruby/spec/jasmine_runner_spec.rb +++ b/contrib/ruby/spec/jasmine_runner_spec.rb @@ -1,12 +1,14 @@ require 'spec' require 'open-uri' +require 'thin' + require File.dirname(__FILE__) + '/../jasmine_runner' describe Jasmine::SimpleServer do before do @port = Jasmine::find_unused_port end - + after do Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid end @@ -25,12 +27,30 @@ describe Jasmine::SimpleServer do run_html.should =~ /