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
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/test/spec_handler.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/test/spec_handler.rb
lack-2.0.0 test/spec_handler.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/test/spec_handler.rb
rack-1.6.0.beta test/spec_handler.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/test/spec_handler.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rack-1.5.2/test/spec_handler.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rack-1.5.2/test/spec_handler.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/rack-1.5.2/test/spec_handler.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/rack-1.3.5/test/spec_handler.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/rack-1.3.5/test/spec_handler.rb
candlepin-api-0.4.0 bundle/ruby/gems/rack-1.3.5/test/spec_handler.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/rack-1.5.2/test/spec_handler.rb
challah-1.0.0 vendor/bundle/gems/rack-1.5.2/test/spec_handler.rb
classiccms-0.7.2 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
classiccms-0.7.1 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
swipe-rails-0.0.5 vendor/bundle/gems/rack-1.4.5/test/spec_handler.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_handler.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_handler.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_handler.rb