Sha256: 9ebd2eff906d3614442414ba51c430ef40e696aa4e45bcb13080c17b66afee9b

Contents?: true

Size: 1.13 KB

Versions: 38

Compression:

Stored size: 1.13 KB

Contents

require File.dirname(__FILE__) + '/../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

38 entries across 38 versions & 6 rubygems

Version Path
grockit-thin-0.8.2 spec/server/builder_spec.rb
macournoyer-thin-1.0.1 spec/server/builder_spec.rb
macournoyer-thin-1.1.0 spec/server/builder_spec.rb
michaelyta-thin-1.2.2 spec/server/builder_spec.rb
thin-1.2.11 spec/server/builder_spec.rb
thin-1.2.11-x86-mswin32 spec/server/builder_spec.rb
thin-1.2.11-x86-mingw32 spec/server/builder_spec.rb
thin-1.2.10 spec/server/builder_spec.rb
thin-1.2.10-x86-mswin32 spec/server/builder_spec.rb
thin-1.2.10-x86-mingw32 spec/server/builder_spec.rb
thin-1.2.9 spec/server/builder_spec.rb
thin-1.2.9-x86-mswin32 spec/server/builder_spec.rb
thin-1.2.9-x86-mingw32 spec/server/builder_spec.rb
thin-1.2.8 spec/server/builder_spec.rb
thin-1.2.8-x86-mswin32 spec/server/builder_spec.rb
thin-1.2.8-x86-mingw32 spec/server/builder_spec.rb
steamcannon-thin-1.2.8 spec/server/builder_spec.rb
thin-1.2.7 spec/server/builder_spec.rb
thin-1.2.7-x86-mswin32 spec/server/builder_spec.rb
thin-1.2.7-x86-mingw32 spec/server/builder_spec.rb