Sha256: e1d2143c6d50d7110de4e963feb64d400191f5c671709c35912531bc1955904f

Contents?: true

Size: 1.74 KB

Versions: 55

Compression:

Stored size: 1.74 KB

Contents

require 'minitest/autorun'
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').must_equal Rack::Handler::CGI
    Rack::Handler.get('webrick').must_equal Rack::Handler::WEBrick

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

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

    lambda {
      Rack::Handler.get('Object')
    }.must_raise(LoadError)
  end

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

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

  it "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').must_equal Rack::Handler::Unregistered
      lambda { Rack::Handler.get('UnRegistered') }.must_raise LoadError
      Rack::Handler.get('UnregisteredLongOne').must_equal Rack::Handler::UnregisteredLongOne
    ensure
      $LOAD_PATH.delete File.expand_path('../unregistered_handler', __FILE__)
    end
  end

  it "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').must_equal Rack::Handler::RegisteringMyself
    ensure
      $LOAD_PATH.delete path
    end
  end
end

Version data entries

55 entries across 53 versions & 14 rubygems

Version Path
rack-2.0.9.4 test/spec_handler.rb
rack-2.0.9.3 test/spec_handler.rb
rack-2.0.9.2 test/spec_handler.rb
rack-2.0.9.1 test/spec_handler.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-2.0.5/test/spec_handler.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rack-2.0.8/test/spec_handler.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/test/spec_handler.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb
rack-2.0.9 test/spec_handler.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rack-2.0.8/test/spec_handler.rb
rack-2.0.8 test/spec_handler.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb
tdiary-5.1.0 vendor/bundle/gems/rack-2.0.7/test/spec_handler.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/test/spec_handler.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rack-2.0.7/test/spec_handler.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/rack-2.0.7/test/spec_handler.rb