More helpful error message when a jasmine server is already running
This commit is contained in:
parent
f9d73761bb
commit
c21431415b
@ -133,7 +133,12 @@ module Jasmine
|
|||||||
JsAlert.new
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
require 'spec'
|
require 'spec'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
|
require 'thin'
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../jasmine_runner'
|
require File.dirname(__FILE__) + '/../jasmine_runner'
|
||||||
|
|
||||||
describe Jasmine::SimpleServer do
|
describe Jasmine::SimpleServer do
|
||||||
before do
|
before do
|
||||||
@port = Jasmine::find_unused_port
|
@port = Jasmine::find_unused_port
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid
|
Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid
|
||||||
end
|
end
|
||||||
@ -25,12 +27,30 @@ describe Jasmine::SimpleServer do
|
|||||||
run_html.should =~ /<script src="file2"/
|
run_html.should =~ /<script src="file2"/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "RuntimeError" do
|
||||||
|
|
||||||
|
it "should throw an Already Running error if there is already a server running" do
|
||||||
|
Thin::Server.should_receive(:start).and_raise(RuntimeError.new('no acceptor'))
|
||||||
|
lambda {
|
||||||
|
Jasmine::SimpleServer.start(@port, ["file1", "file2"], {})
|
||||||
|
}.should raise_error(RuntimeError, "A server is already running on port #{@port}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "re-raises other RuntimeErrors" do
|
||||||
|
Thin::Server.should_receive(:start).and_raise(RuntimeError.new('some random error'))
|
||||||
|
lambda {
|
||||||
|
Jasmine::SimpleServer.start(@port, ["file1", "file2"], {})
|
||||||
|
}.should raise_error(RuntimeError, "some random error")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
it "should take a proc that returns a list of spec files" do
|
it "should take a proc that returns a list of spec files" do
|
||||||
spec_fileses = [["file1", "file2"], ["file1", "file2", "file3"]]
|
spec_fileses = [["file1", "file2"], ["file1", "file2", "file3"]]
|
||||||
spec_files_proc = lambda do
|
spec_files_proc = lambda do
|
||||||
spec_fileses.shift
|
spec_fileses.shift
|
||||||
end
|
end
|
||||||
|
|
||||||
@jasmine_server_pid = fork do
|
@jasmine_server_pid = fork do
|
||||||
Process.setpgrp
|
Process.setpgrp
|
||||||
Jasmine::SimpleServer.start(@port, spec_files_proc, {})
|
Jasmine::SimpleServer.start(@port, spec_files_proc, {})
|
||||||
|
Loading…
Reference in New Issue
Block a user