public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
thin / spec / server_spec.rb
100644 96 lines (74 sloc) 2.444 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require File.dirname(__FILE__) + '/spec_helper'
 
describe Server do
  before do
    @server = Server.new('0.0.0.0', 3000)
  end
  
  it "should set maximum_connections size" do
    @server.maximum_connections = 100
    @server.config
    @server.maximum_connections.should == 100
  end
 
  it "should set lower maximum_connections size when too large" do
    @server.maximum_connections = 100_000
    @server.config
    @server.maximum_connections.should < 100_000
  end
  
  it "should default to non-threaded" do
    @server.should_not be_threaded
  end
  
  it "should set backend to threaded" do
    @server.threaded = true
    @server.backend.should be_threaded
  end
end
 
describe Server, "initialization" do
  it "should set host and port" do
    server = Server.new('192.168.1.1', 8080)
 
    server.host.should == '192.168.1.1'
    server.port.should == 8080
  end
 
  it "should set socket" do
    server = Server.new('/tmp/thin.sock')
 
    server.socket.should == '/tmp/thin.sock'
  end
  
  it "should set host, port and app" do
    app = proc {}
    server = Server.new('192.168.1.1', 8080, app)
    
    server.host.should_not be_nil
    server.app.should == app
  end
 
  it "should set socket and app" do
    app = proc {}
    server = Server.new('/tmp/thin.sock', app)
    
    server.socket.should_not be_nil
    server.app.should == app
  end
 
  it "should set socket, nil and app" do
    app = proc {}
    server = Server.new('/tmp/thin.sock', nil, app)
    
    server.socket.should_not be_nil
    server.app.should == app
  end
  
  it "should set host, port and backend" do
    server = Server.new('192.168.1.1', 8080, :backend => Thin::Backends::SwiftiplyClient)
    
    server.host.should_not be_nil
    server.backend.should be_kind_of(Thin::Backends::SwiftiplyClient)
  end
 
  it "should set host, port, app and backend" do
    app = proc {}
    server = Server.new('192.168.1.1', 8080, app, :backend => Thin::Backends::SwiftiplyClient)
    
    server.host.should_not be_nil
    server.app.should == app
    server.backend.should be_kind_of(Thin::Backends::SwiftiplyClient)
  end
  
  it "should set port as string" do
    app = proc {}
    server = Server.new('192.168.1.1', '8080')
    
    server.host.should == '192.168.1.1'
    server.port.should == 8080
  end
  
  it "should not register signals w/ :signals => false" do
    Server.should_not_receive(:setup_signals)
    Server.new(:signals => false)
  end
end