Sha256: a761ec8a7e6ac5aa3e9eab7c048026586b78d3343956527108f6e1871b53f406

Contents?: true

Size: 1.11 KB

Versions: 48

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe Server, 'app builder' do
  it "should build app from constructor" do
    app = proc {}
    server = Server.new('0.0.0.0', 3000, app)
    
    server.app.should == app
  end
  
  it "should build app from builder block" do
    server = Server.new '0.0.0.0', 3000 do
      run(proc { |env| :works })
    end
    
    server.app.call({}).should == :works
  end
  
  it "should use middlewares in builder block" do
    server = Server.new '0.0.0.0', 3000 do
      use Rack::ShowExceptions
      run(proc { |env| :works })
    end
    
    server.app.class.should == Rack::ShowExceptions
    server.app.call({}).should == :works
  end
  
  it "should work with Rack url mapper" do
    server = Server.new '0.0.0.0', 3000 do
      map '/test' do
        run(proc { |env| [200, {}, 'Found /test'] })
      end
    end
    
    default_env = { 'SCRIPT_NAME' => '' }
    
    server.app.call(default_env.update('PATH_INFO' => '/'))[0].should == 404
    
    status, headers, body = server.app.call(default_env.update('PATH_INFO' => '/test'))
    status.should == 200
    body.should == 'Found /test'
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.7.4 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.7.3 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.7.2 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.7.1 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.7.0 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.9 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.8 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.7 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.6 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.5 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.4 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.3 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.2 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.1 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.6.0 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.5.17 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.5.16 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.5.15 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb
classiccms-0.5.14 vendor/bundle/gems/thin-1.3.1/spec/server/builder_spec.rb