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
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/rack-1.5.5/test/spec_handler.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/rack-1.5.5/test/spec_handler.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/rack-1.5.5/test/spec_handler.rb
classiccms-0.7.5 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
classiccms-0.7.4 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
classiccms-0.7.3 vendor/bundle/gems/rack-1.4.1/test/spec_handler.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rack-1.6.1/test/spec_handler.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_handler.rb
rack-1.4.7 test/spec_handler.rb
rack-1.5.5 test/spec_handler.rb
rack-1.4.6 test/spec_handler.rb
rack-1.5.4 test/spec_handler.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/test/spec_handler.rb
rack-1.5.3 test/spec_handler.rb
rack-1.6.1 test/spec_handler.rb
rack-1.6.0 test/spec_handler.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/test/spec_handler.rb
rack-1.6.0.beta2 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
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/test/spec_handler.rb