rack 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +9 -205
- data/SPEC +3 -3
- data/lib/rack.rb +1 -24
- data/lib/rack/auth/abstract/request.rb +1 -5
- data/lib/rack/auth/digest/md5.rb +1 -2
- data/lib/rack/auth/digest/params.rb +1 -1
- data/lib/rack/content_length.rb +1 -1
- data/lib/rack/etag.rb +15 -6
- data/lib/rack/file.rb +3 -1
- data/lib/rack/handler/cgi.rb +8 -7
- data/lib/rack/handler/fastcgi.rb +1 -1
- data/lib/rack/handler/lsws.rb +1 -1
- data/lib/rack/handler/mongrel.rb +1 -1
- data/lib/rack/handler/scgi.rb +1 -4
- data/lib/rack/handler/webrick.rb +10 -6
- data/lib/rack/lint.rb +29 -37
- data/lib/rack/mime.rb +2 -0
- data/lib/rack/mock.rb +2 -1
- data/lib/rack/recursive.rb +4 -0
- data/lib/rack/request.rb +8 -6
- data/lib/rack/response.rb +1 -0
- data/lib/rack/rewindable_input.rb +13 -10
- data/lib/rack/sendfile.rb +8 -6
- data/lib/rack/server.rb +68 -9
- data/lib/rack/session/cookie.rb +1 -10
- data/lib/rack/session/memcache.rb +1 -1
- data/lib/rack/urlmap.rb +6 -7
- data/lib/rack/utils.rb +40 -71
- data/rack.gemspec +7 -11
- data/spec/cgi/lighttpd.conf +25 -0
- data/spec/cgi/rackup_stub.rb +6 -0
- data/spec/cgi/sample_rackup.ru +5 -0
- data/spec/cgi/test +9 -0
- data/spec/cgi/test.fcgi +8 -0
- data/spec/cgi/test.ru +5 -0
- data/spec/multipart/bad_robots +259 -0
- data/spec/multipart/binary +0 -0
- data/spec/multipart/empty +10 -0
- data/spec/multipart/fail_16384_nofile +814 -0
- data/spec/multipart/file1.txt +1 -0
- data/spec/multipart/filename_and_modification_param +7 -0
- data/spec/multipart/filename_with_escaped_quotes +6 -0
- data/spec/multipart/filename_with_escaped_quotes_and_modification_param +7 -0
- data/spec/multipart/filename_with_percent_escaped_quotes +6 -0
- data/spec/multipart/filename_with_unescaped_quotes +6 -0
- data/spec/multipart/ie +6 -0
- data/spec/multipart/nested +10 -0
- data/spec/multipart/none +9 -0
- data/spec/multipart/semicolon +6 -0
- data/spec/multipart/text +10 -0
- data/spec/rackup/config.ru +31 -0
- data/{test/spec_rack_auth_basic.rb → spec/spec_auth_basic.rb} +11 -14
- data/{test/spec_rack_auth_digest.rb → spec/spec_auth_digest.rb} +18 -27
- data/{test/spec_rack_builder.rb → spec/spec_builder.rb} +49 -10
- data/{test/spec_rack_cascade.rb → spec/spec_cascade.rb} +7 -10
- data/{test/spec_rack_cgi.rb → spec/spec_cgi.rb} +34 -32
- data/{test/spec_rack_chunked.rb → spec/spec_chunked.rb} +8 -10
- data/{test/spec_rack_commonlogger.rb → spec/spec_commonlogger.rb} +10 -15
- data/{test/spec_rack_conditionalget.rb → spec/spec_conditionalget.rb} +5 -7
- data/{test/spec_rack_config.rb → spec/spec_config.rb} +6 -7
- data/{test/spec_rack_content_length.rb → spec/spec_content_length.rb} +7 -8
- data/{test/spec_rack_content_type.rb → spec/spec_content_type.rb} +5 -6
- data/{test/spec_rack_deflater.rb → spec/spec_deflater.rb} +11 -13
- data/{test/spec_rack_directory.rb → spec/spec_directory.rb} +6 -10
- data/{test/spec_rack_etag.rb → spec/spec_etag.rb} +3 -5
- data/{test/spec_rack_fastcgi.rb → spec/spec_fastcgi.rb} +36 -29
- data/{test/spec_rack_file.rb → spec/spec_file.rb} +9 -13
- data/{test/spec_rack_handler.rb → spec/spec_handler.rb} +10 -12
- data/{test/spec_rack_head.rb → spec/spec_head.rb} +3 -3
- data/{test/spec_rack_lint.rb → spec/spec_lint.rb} +19 -32
- data/{test/spec_rack_lobster.rb → spec/spec_lobster.rb} +9 -11
- data/{test/spec_rack_lock.rb → spec/spec_lock.rb} +15 -17
- data/{test/spec_rack_logger.rb → spec/spec_logger.rb} +6 -7
- data/{test/spec_rack_methodoverride.rb → spec/spec_methodoverride.rb} +15 -17
- data/{test/spec_rack_mock.rb → spec/spec_mock.rb} +30 -32
- data/{test/spec_rack_mongrel.rb → spec/spec_mongrel.rb} +40 -46
- data/{test/spec_rack_nulllogger.rb → spec/spec_nulllogger.rb} +4 -5
- data/{test/spec_rack_recursive.rb → spec/spec_recursive.rb} +28 -36
- data/{test/spec_rack_request.rb → spec/spec_request.rb} +84 -98
- data/{test/spec_rack_response.rb → spec/spec_response.rb} +46 -27
- data/spec/spec_rewindable_input.rb +118 -0
- data/{test/spec_rack_runtime.rb → spec/spec_runtime.rb} +15 -11
- data/{test/spec_rack_sendfile.rb → spec/spec_sendfile.rb} +11 -14
- data/{test/spec_rack_session_cookie.rb → spec/spec_session_cookie.rb} +14 -36
- data/{test/spec_rack_session_memcache.rb → spec/spec_session_memcache.rb} +32 -26
- data/{test/spec_rack_session_pool.rb → spec/spec_session_pool.rb} +36 -31
- data/spec/spec_showexceptions.rb +23 -0
- data/spec/spec_showstatus.rb +79 -0
- data/{test/spec_rack_static.rb → spec/spec_static.rb} +5 -9
- data/{test/spec_rack_thin.rb → spec/spec_thin.rb} +30 -35
- data/{test/spec_rack_urlmap.rb → spec/spec_urlmap.rb} +6 -8
- data/{test/spec_rack_utils.rb → spec/spec_utils.rb} +134 -74
- data/{test/spec_rack_webrick.rb → spec/spec_webrick.rb} +28 -36
- data/spec/testrequest.rb +77 -0
- data/spec/unregistered_handler/rack/handler/unregistered.rb +7 -0
- data/spec/unregistered_handler/rack/handler/unregistered_long_one.rb +7 -0
- metadata +176 -191
- data/RDOX +0 -0
- data/lib/rack/adapter/camping.rb +0 -22
- data/test/spec_auth.rb +0 -57
- data/test/spec_rack_camping.rb +0 -55
- data/test/spec_rack_rewindable_input.rb +0 -118
- data/test/spec_rack_showexceptions.rb +0 -21
- data/test/spec_rack_showstatus.rb +0 -72
- data/test/spec_rackup.rb +0 -164
data/RDOX
DELETED
|
File without changes
|
data/lib/rack/adapter/camping.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Rack
|
|
2
|
-
module Adapter
|
|
3
|
-
class Camping
|
|
4
|
-
def initialize(app)
|
|
5
|
-
@app = app
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def call(env)
|
|
9
|
-
env["PATH_INFO"] ||= ""
|
|
10
|
-
env["SCRIPT_NAME"] ||= ""
|
|
11
|
-
controller = @app.run(env['rack.input'], env)
|
|
12
|
-
h = controller.headers
|
|
13
|
-
h.each_pair do |k,v|
|
|
14
|
-
if v.kind_of? URI
|
|
15
|
-
h[k] = v.to_s
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
[controller.status, controller.headers, [controller.body.to_s]]
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
data/test/spec_auth.rb
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
require 'rack'
|
|
2
|
-
|
|
3
|
-
context "Rack::Auth" do
|
|
4
|
-
specify "should have all common authentication schemes" do
|
|
5
|
-
Rack::Auth.schemes.should.include? 'basic'
|
|
6
|
-
Rack::Auth.schemes.should.include? 'digest'
|
|
7
|
-
Rack::Auth.schemes.should.include? 'bearer'
|
|
8
|
-
Rack::Auth.schemes.should.include? 'token'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
specify "should allow registration of new auth schemes" do
|
|
12
|
-
Rack::Auth.schemes.should.not.include "test"
|
|
13
|
-
Rack::Auth.add_scheme "test"
|
|
14
|
-
Rack::Auth.schemes.should.include "test"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "Rack::Auth::AbstractRequest" do
|
|
19
|
-
specify "should symbolize known auth schemes" do
|
|
20
|
-
env = Rack::MockRequest.env_for('/')
|
|
21
|
-
env['HTTP_AUTHORIZATION'] = 'Basic aXJyZXNwb25zaWJsZQ=='
|
|
22
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
23
|
-
req.scheme.should.equal :basic
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
env['HTTP_AUTHORIZATION'] = 'Digest aXJyZXNwb25zaWJsZQ=='
|
|
27
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
28
|
-
req.scheme.should.equal :digest
|
|
29
|
-
|
|
30
|
-
env['HTTP_AUTHORIZATION'] = 'Bearer aXJyZXNwb25zaWJsZQ=='
|
|
31
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
32
|
-
req.scheme.should.equal :bearer
|
|
33
|
-
|
|
34
|
-
env['HTTP_AUTHORIZATION'] = 'MAC aXJyZXNwb25zaWJsZQ=='
|
|
35
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
36
|
-
req.scheme.should.equal :mac
|
|
37
|
-
|
|
38
|
-
env['HTTP_AUTHORIZATION'] = 'Token aXJyZXNwb25zaWJsZQ=='
|
|
39
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
40
|
-
req.scheme.should.equal :token
|
|
41
|
-
|
|
42
|
-
env['HTTP_AUTHORIZATION'] = 'OAuth aXJyZXNwb25zaWJsZQ=='
|
|
43
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
44
|
-
req.scheme.should.equal :oauth
|
|
45
|
-
|
|
46
|
-
env['HTTP_AUTHORIZATION'] = 'OAuth2 aXJyZXNwb25zaWJsZQ=='
|
|
47
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
48
|
-
req.scheme.should.equal :oauth2
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
specify "should not symbolize unknown auth schemes" do
|
|
52
|
-
env = Rack::MockRequest.env_for('/')
|
|
53
|
-
env['HTTP_AUTHORIZATION'] = 'magic aXJyZXNwb25zaWJsZQ=='
|
|
54
|
-
req = Rack::Auth::AbstractRequest.new(env)
|
|
55
|
-
req.scheme.should == "magic"
|
|
56
|
-
end
|
|
57
|
-
end
|
data/test/spec_rack_camping.rb
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require 'test/spec'
|
|
2
|
-
require 'stringio'
|
|
3
|
-
require 'uri'
|
|
4
|
-
|
|
5
|
-
begin
|
|
6
|
-
require 'rack/mock'
|
|
7
|
-
|
|
8
|
-
$-w, w = nil, $-w # yuck
|
|
9
|
-
|
|
10
|
-
# campings dependencies also don't pull this in anymore:
|
|
11
|
-
class Object;def meta_def m,&b;(class<<self;self;end).send:define_method,m,&b end end
|
|
12
|
-
|
|
13
|
-
require 'camping'
|
|
14
|
-
require 'rack/adapter/camping'
|
|
15
|
-
|
|
16
|
-
Camping.goes :CampApp
|
|
17
|
-
module CampApp
|
|
18
|
-
module Controllers
|
|
19
|
-
class HW < R('/')
|
|
20
|
-
def get
|
|
21
|
-
@headers["X-Served-By"] = URI("http://rack.rubyforge.org")
|
|
22
|
-
"Camping works!"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def post
|
|
26
|
-
"Data: #{input.foo}"
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
$-w = w
|
|
32
|
-
|
|
33
|
-
context "Rack::Adapter::Camping" do
|
|
34
|
-
specify "works with GET" do
|
|
35
|
-
res = Rack::MockRequest.new(Rack::Adapter::Camping.new(CampApp)).
|
|
36
|
-
get("/")
|
|
37
|
-
|
|
38
|
-
res.should.be.ok
|
|
39
|
-
res["Content-Type"].should.equal "text/html"
|
|
40
|
-
res["X-Served-By"].should.equal "http://rack.rubyforge.org"
|
|
41
|
-
|
|
42
|
-
res.body.should.equal "Camping works!"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
specify "works with POST" do
|
|
46
|
-
res = Rack::MockRequest.new(Rack::Adapter::Camping.new(CampApp)).
|
|
47
|
-
post("/", :input => "foo=bar")
|
|
48
|
-
|
|
49
|
-
res.should.be.ok
|
|
50
|
-
res.body.should.equal "Data: bar"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
rescue LoadError
|
|
54
|
-
$stderr.puts "Skipping Rack::Adapter::Camping tests (Camping is required). `gem install camping` and try again."
|
|
55
|
-
end
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
require 'test/spec'
|
|
2
|
-
require 'stringio'
|
|
3
|
-
require 'rack/rewindable_input'
|
|
4
|
-
|
|
5
|
-
shared_context "a rewindable IO object" do
|
|
6
|
-
setup do
|
|
7
|
-
@rio = Rack::RewindableInput.new(@io)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
teardown do
|
|
11
|
-
@rio.close
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
specify "should be able to handle to read()" do
|
|
15
|
-
@rio.read.should.equal "hello world"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
specify "should be able to handle to read(nil)" do
|
|
19
|
-
@rio.read(nil).should.equal "hello world"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
specify "should be able to handle to read(length)" do
|
|
23
|
-
@rio.read(1).should.equal "h"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
specify "should be able to handle to read(length, buffer)" do
|
|
27
|
-
buffer = ""
|
|
28
|
-
result = @rio.read(1, buffer)
|
|
29
|
-
result.should.equal "h"
|
|
30
|
-
result.object_id.should.equal buffer.object_id
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
specify "should be able to handle to read(nil, buffer)" do
|
|
34
|
-
buffer = ""
|
|
35
|
-
result = @rio.read(nil, buffer)
|
|
36
|
-
result.should.equal "hello world"
|
|
37
|
-
result.object_id.should.equal buffer.object_id
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
specify "should rewind to the beginning when #rewind is called" do
|
|
41
|
-
@rio.read(1)
|
|
42
|
-
@rio.rewind
|
|
43
|
-
@rio.read.should.equal "hello world"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
specify "should be able to handle gets" do
|
|
47
|
-
@rio.gets.should == "hello world"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
specify "should be able to handle each" do
|
|
51
|
-
array = []
|
|
52
|
-
@rio.each do |data|
|
|
53
|
-
array << data
|
|
54
|
-
end
|
|
55
|
-
array.should.equal(["hello world"])
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
specify "should not buffer into a Tempfile if no data has been read yet" do
|
|
59
|
-
@rio.instance_variable_get(:@rewindable_io).should.be.nil
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
specify "should buffer into a Tempfile when data has been consumed for the first time" do
|
|
63
|
-
@rio.read(1)
|
|
64
|
-
tempfile = @rio.instance_variable_get(:@rewindable_io)
|
|
65
|
-
tempfile.should.not.be.nil
|
|
66
|
-
@rio.read(1)
|
|
67
|
-
tempfile2 = @rio.instance_variable_get(:@rewindable_io)
|
|
68
|
-
tempfile2.should.equal tempfile
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
specify "should close the underlying tempfile upon calling #close" do
|
|
72
|
-
@rio.read(1)
|
|
73
|
-
tempfile = @rio.instance_variable_get(:@rewindable_io)
|
|
74
|
-
@rio.close
|
|
75
|
-
tempfile.should.be.closed
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
specify "should be possibel to call #close when no data has been buffered yet" do
|
|
79
|
-
@rio.close
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
specify "should be possible to call #close multiple times" do
|
|
83
|
-
@rio.close
|
|
84
|
-
@rio.close
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
context "Rack::RewindableInput" do
|
|
89
|
-
context "given an IO object that is already rewindable" do
|
|
90
|
-
setup do
|
|
91
|
-
@io = StringIO.new("hello world")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it_should_behave_like "a rewindable IO object"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context "given an IO object that is not rewindable" do
|
|
98
|
-
setup do
|
|
99
|
-
@io = StringIO.new("hello world")
|
|
100
|
-
@io.instance_eval do
|
|
101
|
-
undef :rewind
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it_should_behave_like "a rewindable IO object"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context "given an IO object whose rewind method raises Errno::ESPIPE" do
|
|
109
|
-
setup do
|
|
110
|
-
@io = StringIO.new("hello world")
|
|
111
|
-
def @io.rewind
|
|
112
|
-
raise Errno::ESPIPE, "You can't rewind this!"
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it_should_behave_like "a rewindable IO object"
|
|
117
|
-
end
|
|
118
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'test/spec'
|
|
2
|
-
|
|
3
|
-
require 'rack/showexceptions'
|
|
4
|
-
require 'rack/mock'
|
|
5
|
-
|
|
6
|
-
context "Rack::ShowExceptions" do
|
|
7
|
-
specify "catches exceptions" do
|
|
8
|
-
res = nil
|
|
9
|
-
req = Rack::MockRequest.new(Rack::ShowExceptions.new(lambda { |env|
|
|
10
|
-
raise RuntimeError
|
|
11
|
-
}))
|
|
12
|
-
lambda {
|
|
13
|
-
res = req.get("/")
|
|
14
|
-
}.should.not.raise
|
|
15
|
-
res.should.be.a.server_error
|
|
16
|
-
res.status.should.equal 500
|
|
17
|
-
|
|
18
|
-
res.should =~ /RuntimeError/
|
|
19
|
-
res.should =~ /ShowExceptions/
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require 'test/spec'
|
|
2
|
-
|
|
3
|
-
require 'rack/showstatus'
|
|
4
|
-
require 'rack/mock'
|
|
5
|
-
|
|
6
|
-
context "Rack::ShowStatus" do
|
|
7
|
-
specify "should provide a default status message" do
|
|
8
|
-
req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env|
|
|
9
|
-
[404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []]
|
|
10
|
-
}))
|
|
11
|
-
|
|
12
|
-
res = req.get("/", :lint => true)
|
|
13
|
-
res.should.be.not_found
|
|
14
|
-
res.should.be.not.empty
|
|
15
|
-
|
|
16
|
-
res["Content-Type"].should.equal("text/html")
|
|
17
|
-
res.should =~ /404/
|
|
18
|
-
res.should =~ /Not Found/
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
specify "should let the app provide additional information" do
|
|
22
|
-
req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env|
|
|
23
|
-
env["rack.showstatus.detail"] = "gone too meta."
|
|
24
|
-
[404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []]
|
|
25
|
-
}))
|
|
26
|
-
|
|
27
|
-
res = req.get("/", :lint => true)
|
|
28
|
-
res.should.be.not_found
|
|
29
|
-
res.should.be.not.empty
|
|
30
|
-
|
|
31
|
-
res["Content-Type"].should.equal("text/html")
|
|
32
|
-
res.should =~ /404/
|
|
33
|
-
res.should =~ /Not Found/
|
|
34
|
-
res.should =~ /too meta/
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
specify "should not replace existing messages" do
|
|
38
|
-
req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env|
|
|
39
|
-
[404, {"Content-Type" => "text/plain", "Content-Length" => "4"}, ["foo!"]]
|
|
40
|
-
}))
|
|
41
|
-
res = req.get("/", :lint => true)
|
|
42
|
-
res.should.be.not_found
|
|
43
|
-
|
|
44
|
-
res.body.should == "foo!"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
specify "should pass on original headers" do
|
|
48
|
-
headers = {"WWW-Authenticate" => "Basic blah"}
|
|
49
|
-
|
|
50
|
-
req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env| [401, headers, []] }))
|
|
51
|
-
res = req.get("/", :lint => true)
|
|
52
|
-
|
|
53
|
-
res["WWW-Authenticate"].should.equal("Basic blah")
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
specify "should replace existing messages if there is detail" do
|
|
57
|
-
req = Rack::MockRequest.new(Rack::ShowStatus.new(lambda { |env|
|
|
58
|
-
env["rack.showstatus.detail"] = "gone too meta."
|
|
59
|
-
[404, {"Content-Type" => "text/plain", "Content-Length" => "4"}, ["foo!"]]
|
|
60
|
-
}))
|
|
61
|
-
|
|
62
|
-
res = req.get("/", :lint => true)
|
|
63
|
-
res.should.be.not_found
|
|
64
|
-
res.should.be.not.empty
|
|
65
|
-
|
|
66
|
-
res["Content-Type"].should.equal("text/html")
|
|
67
|
-
res["Content-Length"].should.not.equal("4")
|
|
68
|
-
res.should =~ /404/
|
|
69
|
-
res.should =~ /too meta/
|
|
70
|
-
res.body.should.not =~ /foo/
|
|
71
|
-
end
|
|
72
|
-
end
|
data/test/spec_rackup.rb
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
require 'test/spec'
|
|
2
|
-
require 'testrequest'
|
|
3
|
-
require 'rack/server'
|
|
4
|
-
require 'open3'
|
|
5
|
-
|
|
6
|
-
begin
|
|
7
|
-
require "mongrel"
|
|
8
|
-
|
|
9
|
-
context "rackup" do
|
|
10
|
-
include TestRequest::Helpers
|
|
11
|
-
|
|
12
|
-
def run_rackup(*args)
|
|
13
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
14
|
-
flags = args.first
|
|
15
|
-
@host = options[:host] || "0.0.0.0"
|
|
16
|
-
@port = options[:port] || 9292
|
|
17
|
-
|
|
18
|
-
Dir.chdir("#{root}/test/rackup") do
|
|
19
|
-
@in, @rackup, @err = Open3.popen3("#{ruby} -S #{rackup} #{flags}")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
return if options[:port] == false
|
|
23
|
-
|
|
24
|
-
# Wait until the server is available
|
|
25
|
-
i = 0
|
|
26
|
-
begin
|
|
27
|
-
GET("/")
|
|
28
|
-
rescue
|
|
29
|
-
i += 1
|
|
30
|
-
if i > 40
|
|
31
|
-
Dir["#{root}/**/*.pid"].each {|f|
|
|
32
|
-
Process.kill(9, File.read(f)) rescue nil
|
|
33
|
-
File.delete(f)
|
|
34
|
-
}
|
|
35
|
-
raise "Server did not start"
|
|
36
|
-
end
|
|
37
|
-
sleep 0.05
|
|
38
|
-
retry
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def output
|
|
43
|
-
@rackup.read
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
after do
|
|
47
|
-
# This doesn't actually return a response, so we rescue
|
|
48
|
-
GET "/die" rescue nil
|
|
49
|
-
|
|
50
|
-
Dir["#{root}/**/*.pid"].each do |file|
|
|
51
|
-
Process.kill(9, File.read(file).strip.to_i) rescue nil
|
|
52
|
-
File.delete(file)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
File.delete("#{root}/log_output") if File.exist?("#{root}/log_output")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
specify "rackup" do
|
|
59
|
-
run_rackup
|
|
60
|
-
response["PATH_INFO"].should.equal '/'
|
|
61
|
-
response["test.$DEBUG"].should.be false
|
|
62
|
-
response["test.$EVAL"].should.be nil
|
|
63
|
-
response["test.$VERBOSE"].should.be false
|
|
64
|
-
response["test.Ping"].should.be nil
|
|
65
|
-
response["SERVER_SOFTWARE"].should.not =~ /webrick/
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
specify "rackup --help" do
|
|
69
|
-
run_rackup "--help", :port => false
|
|
70
|
-
output.should.match /--port/
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
specify "rackup --port" do
|
|
74
|
-
run_rackup "--port 9000", :port => 9000
|
|
75
|
-
response["SERVER_PORT"].should.equal "9000"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
specify "rackup --debug" do
|
|
79
|
-
run_rackup "--debug"
|
|
80
|
-
response["test.$DEBUG"].should.be true
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
specify "rackup --eval" do
|
|
84
|
-
run_rackup %{--eval "BUKKIT = 'BUKKIT'"}
|
|
85
|
-
response["test.$EVAL"].should.equal "BUKKIT"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
specify "rackup --warn" do
|
|
89
|
-
run_rackup %{--warn}
|
|
90
|
-
response["test.$VERBOSE"].should.be true
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
specify "rackup --include" do
|
|
94
|
-
run_rackup %{--include /foo/bar}
|
|
95
|
-
response["test.$LOAD_PATH"].should.include "/foo/bar"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
specify "rackup --require" do
|
|
99
|
-
run_rackup %{--require ping}
|
|
100
|
-
response["test.Ping"].should.equal "constant"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
specify "rackup --server" do
|
|
104
|
-
run_rackup %{--server webrick}
|
|
105
|
-
response["SERVER_SOFTWARE"].should =~ /webrick/i
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
specify "rackup --host" do
|
|
109
|
-
run_rackup %{--host 127.0.0.1}, :host => "127.0.0.1"
|
|
110
|
-
response["REMOTE_ADDR"].should.equal "127.0.0.1"
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
specify "rackup --daemonize --pid" do
|
|
114
|
-
run_rackup "--daemonize --pid testing.pid"
|
|
115
|
-
status.should.be 200
|
|
116
|
-
@rackup.should.be.eof?
|
|
117
|
-
Dir["#{root}/**/testing.pid"].should.not.be.empty?
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
specify "rackup --pid" do
|
|
121
|
-
run_rackup %{--pid testing.pid}
|
|
122
|
-
status.should.be 200
|
|
123
|
-
Dir["#{root}/**/testing.pid"].should.not.be.empty?
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
specify "rackup --version" do
|
|
127
|
-
run_rackup %{--version}, :port => false
|
|
128
|
-
output.should =~ /Rack 1.1/
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
specify "rackup --env development includes lint" do
|
|
132
|
-
run_rackup
|
|
133
|
-
GET("/broken_lint")
|
|
134
|
-
status.should.be 500
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
specify "rackup --env deployment does not include lint" do
|
|
138
|
-
run_rackup %{--env deployment}
|
|
139
|
-
GET("/broken_lint")
|
|
140
|
-
status.should.be 200
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
specify "rackup --env none does not include lint" do
|
|
144
|
-
run_rackup %{--env none}
|
|
145
|
-
GET("/broken_lint")
|
|
146
|
-
status.should.be 200
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
specify "rackup --env deployment does log" do
|
|
150
|
-
run_rackup %{--env deployment}
|
|
151
|
-
log = File.read(response["test.stderr"])
|
|
152
|
-
log.should.be.empty?
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
specify "rackup --env none does not log" do
|
|
156
|
-
run_rackup %{--env none}
|
|
157
|
-
GET("/")
|
|
158
|
-
log = File.read(response["test.stderr"])
|
|
159
|
-
log.should.be.empty?
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
rescue LoadError
|
|
163
|
-
$stderr.puts "Skipping rackup --server tests (mongrel is required). `gem install thin` and try again."
|
|
164
|
-
end
|