2009-12-19 03:16:58 +01:00
|
|
|
require 'rack/handler'
|
|
|
|
|
|
|
|
class Rack::Handler::Lobster; end
|
|
|
|
class RockLobster; end
|
|
|
|
|
2010-06-14 06:09:24 +02:00
|
|
|
describe Rack::Handler do
|
|
|
|
it "has registered default handlers" do
|
2009-12-19 03:16:58 +01:00
|
|
|
Rack::Handler.get('cgi').should.equal Rack::Handler::CGI
|
|
|
|
Rack::Handler.get('fastcgi').should.equal Rack::Handler::FastCGI
|
|
|
|
Rack::Handler.get('mongrel').should.equal Rack::Handler::Mongrel
|
|
|
|
Rack::Handler.get('webrick').should.equal Rack::Handler::WEBrick
|
|
|
|
end
|
2010-06-14 06:09:24 +02:00
|
|
|
|
|
|
|
should "raise NameError if handler doesn't exist" do
|
2009-12-19 03:16:58 +01:00
|
|
|
lambda {
|
|
|
|
Rack::Handler.get('boom')
|
|
|
|
}.should.raise(NameError)
|
|
|
|
end
|
|
|
|
|
2010-06-14 06:09:24 +02:00
|
|
|
should "get unregistered, but already required, handler by name" do
|
2009-12-19 03:16:58 +01:00
|
|
|
Rack::Handler.get('Lobster').should.equal Rack::Handler::Lobster
|
|
|
|
end
|
|
|
|
|
2010-06-14 06:09:24 +02:00
|
|
|
should "register custom handler" do
|
2009-12-19 03:16:58 +01:00
|
|
|
Rack::Handler.register('rock_lobster', 'RockLobster')
|
|
|
|
Rack::Handler.get('rock_lobster').should.equal RockLobster
|
|
|
|
end
|
2010-06-14 06:09:24 +02:00
|
|
|
|
|
|
|
should "not need registration for properly coded handlers even if not already required" do
|
2009-12-19 03:16:58 +01:00
|
|
|
begin
|
2010-06-14 06:09:24 +02:00
|
|
|
$LOAD_PATH.push File.expand_path('../unregistered_handler', __FILE__)
|
2009-12-19 03:16:58 +01:00
|
|
|
Rack::Handler.get('Unregistered').should.equal Rack::Handler::Unregistered
|
|
|
|
lambda {
|
|
|
|
Rack::Handler.get('UnRegistered')
|
|
|
|
}.should.raise(NameError)
|
|
|
|
Rack::Handler.get('UnregisteredLongOne').should.equal Rack::Handler::UnregisteredLongOne
|
|
|
|
ensure
|
2010-06-14 06:09:24 +02:00
|
|
|
$LOAD_PATH.delete File.expand_path('../unregistered_handler', __FILE__)
|
2009-12-19 03:16:58 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|