Sha256: 29c6b3ba21a08924da75891b07dbcbcd0accd58cd658ee7038ba18cf9ed41252

Contents?: true

Size: 1.8 KB

Versions: 214

Compression:

Stored size: 1.8 KB

Contents

require 'rack/handler'

class Rack::Handler::Lobster; end
class RockLobster; end

describe Rack::Handler do
  it "has registered default handlers" do
    Rack::Handler.get('cgi').should.equal Rack::Handler::CGI
    Rack::Handler.get('webrick').should.equal Rack::Handler::WEBrick

    begin
      Rack::Handler.get('fastcgi').should.equal Rack::Handler::FastCGI
    rescue LoadError
    end

    begin
      Rack::Handler.get('mongrel').should.equal Rack::Handler::Mongrel
    rescue LoadError
    end
  end

  should "raise LoadError if handler doesn't exist" do
    lambda {
      Rack::Handler.get('boom')
    }.should.raise(LoadError)
  end

  should "get unregistered, but already required, handler by name" do
    Rack::Handler.get('Lobster').should.equal Rack::Handler::Lobster
  end

  should "register custom handler" do
    Rack::Handler.register('rock_lobster', 'RockLobster')
    Rack::Handler.get('rock_lobster').should.equal RockLobster
  end

  should "not need registration for properly coded handlers even if not already required" do
    begin
      $LOAD_PATH.push File.expand_path('../unregistered_handler', __FILE__)
      Rack::Handler.get('Unregistered').should.equal Rack::Handler::Unregistered
      lambda {
        Rack::Handler.get('UnRegistered')
      }.should.raise LoadError
      Rack::Handler.get('UnregisteredLongOne').should.equal Rack::Handler::UnregisteredLongOne
    ensure
      $LOAD_PATH.delete File.expand_path('../unregistered_handler', __FILE__)
    end
  end

  should "allow autoloaded handlers to be registered properly while being loaded" do
    path = File.expand_path('../registering_handler', __FILE__)
    begin
      $LOAD_PATH.push path
      Rack::Handler.get('registering_myself').should.equal Rack::Handler::RegisteringMyself
    ensure
      $LOAD_PATH.delete path
    end
  end
end

Version data entries

214 entries across 182 versions & 36 rubygems

Version Path
challah-0.2.1 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
challah-0.2.0 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
rack-1.4.1 test/spec_handler.rb
rack-1.4.0 test/spec_handler.rb
rack-1.3.6 test/spec_handler.rb
rack-1.3.5 test/spec_handler.rb
rack-1.3.4 test/spec_handler.rb
rack-1.3.3 test/spec_handler.rb
rack-1.3.2 test/spec_handler.rb
rack-1.3.1 test/spec_handler.rb
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/rack-1.3.0/test/spec_handler.rb
rack-1.3.0 test/spec_handler.rb
rack-1.3.0.beta2 test/spec_handler.rb
rack-1.3.0.beta test/spec_handler.rb