Sha256: 140e6a1e9648d36f1f6163eab6dc238935597e921a529d3038223dc8373572f7

Contents?: true

Size: 1.39 KB

Versions: 35

Compression:

Stored size: 1.39 KB

Contents

require 'test/spec'

require 'rack/handler'

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

context "Rack::Handler" do
  specify "has registered default handlers" do
    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
  
  specify "handler that doesn't exist should raise a NameError" do
    lambda {
      Rack::Handler.get('boom')
    }.should.raise(NameError)
  end

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

  specify "should register custom handler" do
    Rack::Handler.register('rock_lobster', 'RockLobster')
    Rack::Handler.get('rock_lobster').should.equal RockLobster
  end
  
  specify "should not need registration for properly coded handlers even if not already required" do
    begin
      $:.push "test/unregistered_handler"
      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
      $:.delete "test/unregistered_handler"
    end
  end
end

Version data entries

35 entries across 34 versions & 12 rubygems

Version Path
kjvarga-rack-1.0.0 test/spec_rack_handler.rb
qoobaa-rack-1.0.0.1 test/spec_rack_handler.rb
qoobaa-rack-1.0.2 test/spec_rack_handler.rb
timocratic-rack-1.0.0 test/spec_rack_handler.rb
rack-1.1.6 test/spec_rack_handler.rb
rack-1.1.5 test/spec_rack_handler.rb
rack-1.1.4 test/spec_rack_handler.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rack-1.1.3/test/spec_rack_handler.rb
rack-1.1.3 test/spec_rack_handler.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/rack-1.1.2/test/spec_rack_handler.rb
rack-1.1.2 test/spec_rack_handler.rb
rack-1.1.1 test/spec_rack_handler.rb
rack-1.1.1.pre test/spec_rack_handler.rb
eac-rack-1.1.1 test/spec_rack_handler.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_handler.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_handler.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/rack-1.1.0/test/spec_rack_handler.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_handler.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/rack-1.1.0/test/spec_rack_handler.rb
rack-1.1.0 test/spec_rack_handler.rb