mongrel2 0.38.0 → 0.39.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +6 -0
- data/Manifest.txt +5 -3
- data/Rakefile +2 -2
- data/data/mongrel2/config.sql +6 -1
- data/lib/mongrel2.rb +5 -2
- data/lib/mongrel2/config.rb +1 -0
- data/lib/mongrel2/config/server.rb +15 -0
- data/lib/mongrel2/config/xrequest.rb +45 -0
- data/lib/mongrel2/connection.rb +4 -5
- data/lib/mongrel2/control.rb +2 -2
- data/lib/mongrel2/handler.rb +1 -1
- data/spec/{lib/constants.rb → constants.rb} +0 -2
- data/spec/{lib/helpers.rb → helpers.rb} +9 -12
- data/spec/{lib/matchers.rb → matchers.rb} +2 -12
- data/spec/mongrel2/config/directory_spec.rb +16 -27
- data/spec/mongrel2/config/dsl_spec.rb +115 -98
- data/spec/mongrel2/config/filter_spec.rb +1 -12
- data/spec/mongrel2/config/handler_spec.rb +23 -33
- data/spec/mongrel2/config/host_spec.rb +1 -12
- data/spec/mongrel2/config/log_spec.rb +13 -24
- data/spec/mongrel2/config/proxy_spec.rb +1 -12
- data/spec/mongrel2/config/route_spec.rb +5 -15
- data/spec/mongrel2/config/server_spec.rb +23 -34
- data/spec/mongrel2/config/setting_spec.rb +1 -12
- data/spec/mongrel2/config/statistic_spec.rb +1 -12
- data/spec/mongrel2/config/xrequest_spec.rb +19 -0
- data/spec/mongrel2/config_spec.rb +17 -29
- data/spec/mongrel2/connection_spec.rb +41 -53
- data/spec/mongrel2/constants_spec.rb +2 -14
- data/spec/mongrel2/control_spec.rb +44 -56
- data/spec/mongrel2/handler_spec.rb +64 -76
- data/spec/mongrel2/httprequest_spec.rb +21 -31
- data/spec/mongrel2/httpresponse_spec.rb +55 -67
- data/spec/mongrel2/request_spec.rb +53 -62
- data/spec/mongrel2/response_spec.rb +15 -24
- data/spec/mongrel2/table_spec.rb +41 -53
- data/spec/mongrel2/websocket_spec.rb +95 -104
- data/spec/mongrel2_spec.rb +3 -12
- metadata +13 -11
- metadata.gz.sig +0 -0
@@ -1,22 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
10
|
-
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
|
-
}
|
3
|
+
require_relative '../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
6
|
+
|
14
7
|
require 'tnetstring'
|
15
8
|
require 'tmpdir'
|
16
9
|
require 'tempfile'
|
17
10
|
|
18
|
-
require 'spec/lib/helpers'
|
19
|
-
|
20
11
|
require 'mongrel2'
|
21
12
|
require 'mongrel2/request'
|
22
13
|
|
@@ -28,7 +19,7 @@ require 'mongrel2/request'
|
|
28
19
|
describe Mongrel2::Request do
|
29
20
|
|
30
21
|
before( :all ) do
|
31
|
-
setup_logging(
|
22
|
+
setup_logging()
|
32
23
|
@factory = Mongrel2::RequestFactory.new( route: '/form' )
|
33
24
|
end
|
34
25
|
|
@@ -42,12 +33,12 @@ describe Mongrel2::Request do
|
|
42
33
|
message = make_request()
|
43
34
|
req = Mongrel2::Request.parse( message )
|
44
35
|
|
45
|
-
req.
|
46
|
-
req.sender_id.
|
47
|
-
req.conn_id.
|
36
|
+
expect( req ).to be_a( Mongrel2::Request )
|
37
|
+
expect( req.sender_id ).to eq( TEST_UUID )
|
38
|
+
expect( req.conn_id ).to eq( TEST_ID )
|
48
39
|
|
49
|
-
req.headers.
|
50
|
-
req.headers['Host'].
|
40
|
+
expect( req.headers ).to be_a( Mongrel2::Table )
|
41
|
+
expect( req.headers['Host'] ).to eq( TEST_HEADERS['host'] )
|
51
42
|
end
|
52
43
|
|
53
44
|
it "can parse a request message with TNetstring headers" do
|
@@ -55,12 +46,12 @@ describe Mongrel2::Request do
|
|
55
46
|
message = make_tn_request()
|
56
47
|
req = Mongrel2::Request.parse( message )
|
57
48
|
|
58
|
-
req.
|
59
|
-
req.sender_id.
|
60
|
-
req.conn_id.
|
49
|
+
expect( req ).to be_a( Mongrel2::Request )
|
50
|
+
expect( req.sender_id ).to eq( TEST_UUID )
|
51
|
+
expect( req.conn_id ).to eq( TEST_ID )
|
61
52
|
|
62
|
-
req.headers.
|
63
|
-
req.headers.host.
|
53
|
+
expect( req.headers ).to be_a( Mongrel2::Table )
|
54
|
+
expect( req.headers.host ).to eq( TEST_HEADERS['host'] )
|
64
55
|
end
|
65
56
|
|
66
57
|
it "can parse a request message with a JSON body" do
|
@@ -68,14 +59,14 @@ describe Mongrel2::Request do
|
|
68
59
|
message = make_json_request()
|
69
60
|
req = Mongrel2::Request.parse( message )
|
70
61
|
|
71
|
-
req.
|
72
|
-
req.sender_id.
|
73
|
-
req.conn_id.
|
62
|
+
expect( req ).to be_a( Mongrel2::JSONRequest )
|
63
|
+
expect( req.sender_id ).to eq( TEST_UUID )
|
64
|
+
expect( req.conn_id ).to eq( TEST_ID )
|
74
65
|
|
75
|
-
req.headers.
|
76
|
-
req.headers.path.
|
66
|
+
expect( req.headers ).to be_a( Mongrel2::Table )
|
67
|
+
expect( req.headers.path ).to eq( TEST_JSON_PATH )
|
77
68
|
|
78
|
-
req.data.
|
69
|
+
expect( req.data ).to eq( TEST_JSON_BODY )
|
79
70
|
end
|
80
71
|
|
81
72
|
it "raises an UnhandledMethodError with the name of the method for METHOD verbs that " +
|
@@ -86,7 +77,7 @@ describe Mongrel2::Request do
|
|
86
77
|
end
|
87
78
|
|
88
79
|
it "knows what kind of response it should return" do
|
89
|
-
Mongrel2::Request.response_class.
|
80
|
+
expect( Mongrel2::Request.response_class ).to eq( Mongrel2::Response )
|
90
81
|
end
|
91
82
|
|
92
83
|
|
@@ -99,39 +90,39 @@ describe Mongrel2::Request do
|
|
99
90
|
|
100
91
|
it "can return an appropriate response instance for themselves" do
|
101
92
|
result = @req.response
|
102
|
-
result.
|
103
|
-
result.sender_id.
|
104
|
-
result.conn_id.
|
93
|
+
expect( result ).to be_a( Mongrel2::Response )
|
94
|
+
expect( result.sender_id ).to eq( @req.sender_id )
|
95
|
+
expect( result.conn_id ).to eq( @req.conn_id )
|
105
96
|
end
|
106
97
|
|
107
98
|
it "remembers its response if it's already made one" do
|
108
|
-
@req.response.
|
99
|
+
expect( @req.response ).to equal( @req.response )
|
109
100
|
end
|
110
101
|
|
111
102
|
it "allows the entity body to be replaced by assigning a String" do
|
112
103
|
@req.body = 'something else'
|
113
|
-
@req.body.
|
114
|
-
@req.body.string.
|
104
|
+
expect( @req.body ).to be_a( StringIO )
|
105
|
+
expect( @req.body.string ).to eq( 'something else' )
|
115
106
|
end
|
116
107
|
|
117
108
|
it "doesn't try to wrap non-stringish entity body replacements in a StringIO" do
|
118
109
|
testobj = Object.new
|
119
110
|
@req.body = testobj
|
120
|
-
@req.body.
|
111
|
+
expect( @req.body ).to be( testobj )
|
121
112
|
end
|
122
113
|
|
123
114
|
it "provides a convenience method for fetching the requestor's IP address" do
|
124
115
|
@req.headers.merge!(
|
125
116
|
'X-Forwarded-For' => '127.0.0.1'
|
126
117
|
)
|
127
|
-
@req.remote_ip.to_s.
|
118
|
+
expect( @req.remote_ip.to_s ).to eq( '127.0.0.1' )
|
128
119
|
end
|
129
120
|
|
130
121
|
it "fetching the requestor's IP address even when travelling via proxies" do
|
131
122
|
@req.headers.merge!(
|
132
123
|
'X-Forwarded-For' => [ '127.0.0.1', '8.8.8.8', '4.4.4.4' ]
|
133
124
|
)
|
134
|
-
@req.remote_ip.to_s.
|
125
|
+
expect( @req.remote_ip.to_s ).to eq( '127.0.0.1' )
|
135
126
|
end
|
136
127
|
|
137
128
|
end
|
@@ -143,21 +134,21 @@ describe Mongrel2::Request do
|
|
143
134
|
body = "some data".encode( 'binary' )
|
144
135
|
req = @factory.post( '/form', body, content_type: 'text/plain; charset=iso-8859-1' )
|
145
136
|
|
146
|
-
req.body.string.encoding.
|
137
|
+
expect( req.body.string.encoding ).to be( Encoding::ISO_8859_1 )
|
147
138
|
end
|
148
139
|
|
149
140
|
it "keeps the data as ascii-8bit if no charset is in the content-type header" do
|
150
141
|
body = "some data".encode( 'binary' )
|
151
142
|
req = @factory.post( '/form', body, content_type: 'application/octet-stream' )
|
152
143
|
|
153
|
-
req.body.string.encoding.
|
144
|
+
expect( req.body.string.encoding ).to be( Encoding::ASCII_8BIT )
|
154
145
|
end
|
155
146
|
|
156
147
|
it "keeps the data as ascii-8bit if there is no content-type header" do
|
157
148
|
body = "some data".encode( 'binary' )
|
158
149
|
req = @factory.post( '/form', body )
|
159
150
|
|
160
|
-
req.body.string.encoding.
|
151
|
+
expect( req.body.string.encoding ).to be( Encoding::ASCII_8BIT )
|
161
152
|
end
|
162
153
|
|
163
154
|
end
|
@@ -185,9 +176,9 @@ describe Mongrel2::Request do
|
|
185
176
|
register_request_type self, :__default
|
186
177
|
end
|
187
178
|
|
188
|
-
Mongrel2::Request.subclass_for_method( 'GET' ).
|
189
|
-
Mongrel2::Request.subclass_for_method( 'POST' ).
|
190
|
-
Mongrel2::Request.subclass_for_method( 'JSON' ).
|
179
|
+
expect( Mongrel2::Request.subclass_for_method( 'GET' ) ).to eq( subclass )
|
180
|
+
expect( Mongrel2::Request.subclass_for_method( 'POST' ) ).to eq( subclass )
|
181
|
+
expect( Mongrel2::Request.subclass_for_method( 'JSON' ) ).to eq( subclass )
|
191
182
|
end
|
192
183
|
|
193
184
|
it "includes a mechanism for overriding the Request subclass for a particular request " +
|
@@ -196,9 +187,9 @@ describe Mongrel2::Request do
|
|
196
187
|
register_request_type self, :GET
|
197
188
|
end
|
198
189
|
|
199
|
-
Mongrel2::Request.subclass_for_method( 'GET' ).
|
200
|
-
Mongrel2::Request.subclass_for_method( 'POST' ).
|
201
|
-
Mongrel2::Request.subclass_for_method( 'JSON' ).
|
190
|
+
expect( Mongrel2::Request.subclass_for_method( 'GET' ) ).to eq( subclass )
|
191
|
+
expect( Mongrel2::Request.subclass_for_method( 'POST' ) ).to_not eq( subclass )
|
192
|
+
expect( Mongrel2::Request.subclass_for_method( 'JSON' ) ).to_not eq( subclass )
|
202
193
|
end
|
203
194
|
|
204
195
|
it "clears any cached method -> subclass lookups when the default subclass changes" do
|
@@ -208,7 +199,7 @@ describe Mongrel2::Request do
|
|
208
199
|
register_request_type self, :__default
|
209
200
|
end
|
210
201
|
|
211
|
-
Mongrel2::Request.subclass_for_method( 'OPTIONS' ).
|
202
|
+
expect( Mongrel2::Request.subclass_for_method( 'OPTIONS' ) ).to eq( subclass )
|
212
203
|
end
|
213
204
|
|
214
205
|
end
|
@@ -243,8 +234,8 @@ describe Mongrel2::Request do
|
|
243
234
|
it "knows if it's an 'async upload started' notification" do
|
244
235
|
req = @factory.post( '/form', '', x_mongrel2_upload_start: @spoolpath )
|
245
236
|
|
246
|
-
req.
|
247
|
-
req.
|
237
|
+
expect( req ).to be_upload_started()
|
238
|
+
expect( req ).to_not be_upload_done()
|
248
239
|
end
|
249
240
|
|
250
241
|
it "knows if it's an 'async upload done' notification" do
|
@@ -252,9 +243,9 @@ describe Mongrel2::Request do
|
|
252
243
|
x_mongrel2_upload_start: @spoolpath,
|
253
244
|
x_mongrel2_upload_done: @spoolpath )
|
254
245
|
|
255
|
-
req.
|
256
|
-
req.
|
257
|
-
req.
|
246
|
+
expect( req ).to_not be_upload_started()
|
247
|
+
expect( req ).to be_upload_done()
|
248
|
+
expect( req ).to be_valid_upload()
|
258
249
|
end
|
259
250
|
|
260
251
|
it "knows if it's not a valid 'async upload done' notification" do
|
@@ -262,9 +253,9 @@ describe Mongrel2::Request do
|
|
262
253
|
x_mongrel2_upload_start: @spoolpath,
|
263
254
|
x_mongrel2_upload_done: '/etc/passwd' )
|
264
255
|
|
265
|
-
req.
|
266
|
-
req.
|
267
|
-
req.
|
256
|
+
expect( req ).to_not be_upload_started()
|
257
|
+
expect( req ).to be_upload_done()
|
258
|
+
expect( req ).to_not be_valid_upload()
|
268
259
|
end
|
269
260
|
|
270
261
|
it "raises an exception if the uploaded file fetched with mismatched headers" do
|
@@ -282,10 +273,10 @@ describe Mongrel2::Request do
|
|
282
273
|
x_mongrel2_upload_start: @spoolpath,
|
283
274
|
x_mongrel2_upload_done: @spoolpath )
|
284
275
|
|
285
|
-
req.
|
276
|
+
expect( req ).to be_valid_upload()
|
286
277
|
|
287
|
-
req.uploaded_file.
|
288
|
-
req.uploaded_file.to_s.
|
278
|
+
expect( req.uploaded_file ).to be_a( Pathname )
|
279
|
+
expect( req.uploaded_file.to_s ).to eq( @spoolfile.path )
|
289
280
|
end
|
290
281
|
|
291
282
|
it "sets the body of the request to the uploaded File if it's valid" do
|
@@ -293,10 +284,10 @@ describe Mongrel2::Request do
|
|
293
284
|
x_mongrel2_upload_start: @spoolpath,
|
294
285
|
x_mongrel2_upload_done: @spoolpath )
|
295
286
|
|
296
|
-
req.
|
287
|
+
expect( req ).to be_valid_upload()
|
297
288
|
|
298
|
-
req.body.
|
299
|
-
req.body.path.
|
289
|
+
expect( req.body ).to be_a( File )
|
290
|
+
expect( req.body.path ).to eq( @spoolfile.path )
|
300
291
|
end
|
301
292
|
|
302
293
|
end
|
@@ -1,19 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
10
|
-
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
|
-
}
|
3
|
+
require_relative '../helpers'
|
12
4
|
|
13
5
|
require 'rspec'
|
14
|
-
require 'tnetstring'
|
15
6
|
|
16
|
-
require '
|
7
|
+
require 'tnetstring'
|
17
8
|
|
18
9
|
require 'mongrel2'
|
19
10
|
require 'mongrel2/request'
|
@@ -27,7 +18,7 @@ require 'mongrel2/response'
|
|
27
18
|
describe Mongrel2::Response do
|
28
19
|
|
29
20
|
before( :all ) do
|
30
|
-
setup_logging(
|
21
|
+
setup_logging()
|
31
22
|
end
|
32
23
|
|
33
24
|
after( :all ) do
|
@@ -39,21 +30,21 @@ describe Mongrel2::Response do
|
|
39
30
|
req = Mongrel2::Request.new( TEST_UUID, 8, '/path', {}, '' )
|
40
31
|
response = Mongrel2::Response.from_request( req )
|
41
32
|
|
42
|
-
response.
|
43
|
-
response.sender_id.
|
44
|
-
response.conn_id.
|
45
|
-
response.request.
|
33
|
+
expect( response ).to be_a( Mongrel2::Response )
|
34
|
+
expect( response.sender_id ).to eq( req.sender_id )
|
35
|
+
expect( response.conn_id ).to eq( req.conn_id )
|
36
|
+
expect( response.request ).to equal( req )
|
46
37
|
end
|
47
38
|
|
48
39
|
|
49
40
|
it "can be created with a body" do
|
50
41
|
response = Mongrel2::Response.new( TEST_UUID, 8, 'the body' )
|
51
|
-
response.body.read.
|
42
|
+
expect( response.body.read ).to eq( 'the body' )
|
52
43
|
end
|
53
44
|
|
54
45
|
it "stringifies to its body contents" do
|
55
46
|
response = Mongrel2::Response.new( TEST_UUID, 8, 'the body' )
|
56
|
-
response.to_s.
|
47
|
+
expect( response.to_s ).to eq( 'the body' )
|
57
48
|
end
|
58
49
|
|
59
50
|
it "can be streamed in chunks" do
|
@@ -64,15 +55,15 @@ describe Mongrel2::Response do
|
|
64
55
|
it "wraps stringifiable bodies set via the #body= accessor in a StringIO" do
|
65
56
|
response = Mongrel2::Response.new( TEST_UUID, 8 )
|
66
57
|
response.body = 'a stringioed body'
|
67
|
-
response.body.
|
68
|
-
response.body.string.
|
58
|
+
expect( response.body ).to be_a( StringIO )
|
59
|
+
expect( response.body.string ).to eq( 'a stringioed body' )
|
69
60
|
end
|
70
61
|
|
71
62
|
it "doesn't try to wrap non-stringfiable bodies in a StringIO" do
|
72
63
|
response = Mongrel2::Response.new( TEST_UUID, 8 )
|
73
64
|
testbody = Object.new
|
74
65
|
response.body = testbody
|
75
|
-
response.body.
|
66
|
+
expect( response.body ).to be( testbody )
|
76
67
|
end
|
77
68
|
|
78
69
|
context "an instance with default values" do
|
@@ -83,19 +74,19 @@ describe Mongrel2::Response do
|
|
83
74
|
|
84
75
|
it "has an empty-IO body" do
|
85
76
|
@response.body.rewind
|
86
|
-
@response.body.read.
|
77
|
+
expect( @response.body.read ).to eq( '' )
|
87
78
|
end
|
88
79
|
|
89
80
|
it "supports the append operator to append objects to the body IO" do
|
90
81
|
@response << 'some body stuff' << ' and some more body stuff'
|
91
82
|
@response.body.rewind
|
92
|
-
@response.body.read.
|
83
|
+
expect( @response.body.read ).to eq( 'some body stuff and some more body stuff' )
|
93
84
|
end
|
94
85
|
|
95
86
|
it "supports #puts for appending objects to the body IO separated by EOL" do
|
96
87
|
@response.puts( "some body stuff\n", " and some more body stuff\n\n", :and_a_symbol )
|
97
88
|
@response.body.rewind
|
98
|
-
@response.body.read.
|
89
|
+
expect( @response.body.read ).to eq( "some body stuff\n and some more body stuff\n\nand_a_symbol\n" )
|
99
90
|
end
|
100
91
|
|
101
92
|
end
|
data/spec/mongrel2/table_spec.rb
CHANGED
@@ -1,18 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
-
|
7
|
-
libdir = basedir + "lib"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
10
|
-
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
|
15
|
-
require 'spec/lib/helpers'
|
3
|
+
require_relative '../helpers'
|
16
4
|
|
17
5
|
require 'mongrel2'
|
18
6
|
require 'mongrel2/table'
|
@@ -26,7 +14,7 @@ describe Mongrel2::Table do
|
|
26
14
|
|
27
15
|
|
28
16
|
before( :all ) do
|
29
|
-
setup_logging(
|
17
|
+
setup_logging()
|
30
18
|
end
|
31
19
|
|
32
20
|
before( :each ) do
|
@@ -46,38 +34,38 @@ describe Mongrel2::Table do
|
|
46
34
|
@table[:accept_encoding] = :accept_encoding
|
47
35
|
@table.accept_encoding = :accept_encoding
|
48
36
|
|
49
|
-
@table['accept'].
|
50
|
-
@table['ACCEPT'].
|
51
|
-
@table['Accept'].
|
52
|
-
@table[:accept].
|
53
|
-
@table.accept.
|
54
|
-
|
55
|
-
@table['USER-AGENT'].
|
56
|
-
@table['User-Agent'].
|
57
|
-
@table['user-agent'].
|
58
|
-
@table[:user_agent].
|
59
|
-
@table.user_agent.
|
60
|
-
|
61
|
-
@table['ACCEPT-ENCODING'].
|
62
|
-
@table['Accept-Encoding'].
|
63
|
-
@table['accept-encoding'].
|
64
|
-
@table[:accept_encoding].
|
65
|
-
@table.accept_encoding.
|
37
|
+
expect( @table['accept'] ).to eq( :accept )
|
38
|
+
expect( @table['ACCEPT'] ).to eq( :accept )
|
39
|
+
expect( @table['Accept'] ).to eq( :accept )
|
40
|
+
expect( @table[:accept] ).to eq( :accept )
|
41
|
+
expect( @table.accept ).to eq( :accept )
|
42
|
+
|
43
|
+
expect( @table['USER-AGENT'] ).to eq( :user_agent )
|
44
|
+
expect( @table['User-Agent'] ).to eq( :user_agent )
|
45
|
+
expect( @table['user-agent'] ).to eq( :user_agent )
|
46
|
+
expect( @table[:user_agent] ).to eq( :user_agent )
|
47
|
+
expect( @table.user_agent ).to eq( :user_agent )
|
48
|
+
|
49
|
+
expect( @table['ACCEPT-ENCODING'] ).to eq( :accept_encoding )
|
50
|
+
expect( @table['Accept-Encoding'] ).to eq( :accept_encoding )
|
51
|
+
expect( @table['accept-encoding'] ).to eq( :accept_encoding )
|
52
|
+
expect( @table[:accept_encoding] ).to eq( :accept_encoding )
|
53
|
+
expect( @table.accept_encoding ).to eq( :accept_encoding )
|
66
54
|
end
|
67
55
|
|
68
56
|
|
69
57
|
it "should assign a new value when appending to a non-existing key" do
|
70
58
|
@table.append( 'indian-meal' => 'pinecones' )
|
71
|
-
@table['Indian-Meal'].
|
59
|
+
expect( @table['Indian-Meal'] ).to eq( 'pinecones' )
|
72
60
|
end
|
73
61
|
|
74
62
|
|
75
63
|
it "should create an array value and append when appending to an existing key" do
|
76
64
|
@table[:indian_meal] = 'pork sausage'
|
77
65
|
@table.append( 'Indian-MEAL' => 'pinecones' )
|
78
|
-
@table['Indian-Meal'].
|
79
|
-
@table['Indian-Meal'].
|
80
|
-
@table['Indian-Meal'].
|
66
|
+
expect( @table['Indian-Meal'] ).to have(2).members
|
67
|
+
expect( @table['Indian-Meal'] ).to include('pinecones')
|
68
|
+
expect( @table['Indian-Meal'] ).to include('pork sausage')
|
81
69
|
end
|
82
70
|
|
83
71
|
|
@@ -86,9 +74,9 @@ describe Mongrel2::Table do
|
|
86
74
|
|
87
75
|
table = Mongrel2::Table.new({ :bob => :dan, 'Bob' => :dan_too })
|
88
76
|
|
89
|
-
table[:bob].
|
90
|
-
table['Bob'].
|
91
|
-
table['bob'].
|
77
|
+
expect( table[:bob] ).to have(2).members
|
78
|
+
expect( table['Bob'] ).to include( :dan )
|
79
|
+
expect( table['bob'] ).to include( :dan_too )
|
92
80
|
end
|
93
81
|
|
94
82
|
|
@@ -100,9 +88,9 @@ describe Mongrel2::Table do
|
|
100
88
|
|
101
89
|
table.append( 'x-ice-cream-flavor' => 'banana' )
|
102
90
|
|
103
|
-
table.to_s.
|
104
|
-
table.to_s.
|
105
|
-
table.to_s.
|
91
|
+
expect( table.to_s ).to match( %r{Accept: text/html\r\n} )
|
92
|
+
expect( table.to_s ).to match( %r{X-Ice-Cream-Flavor: mango\r\n} )
|
93
|
+
expect( table.to_s ).to match( %r{X-Ice-Cream-Flavor: banana\r\n} )
|
106
94
|
end
|
107
95
|
|
108
96
|
|
@@ -115,8 +103,8 @@ describe Mongrel2::Table do
|
|
115
103
|
othertable['cookie'] = 'peanut butter'
|
116
104
|
|
117
105
|
ot = @table.merge( othertable )
|
118
|
-
ot['accept'].
|
119
|
-
ot['cookie'].
|
106
|
+
expect( ot['accept'] ).to eq( 'thing' )
|
107
|
+
expect( ot['cookie'] ).to eq( 'peanut butter' )
|
120
108
|
end
|
121
109
|
|
122
110
|
|
@@ -127,8 +115,8 @@ describe Mongrel2::Table do
|
|
127
115
|
hash = { 'CookiE_FLAVOR' => 'peanut butter' }
|
128
116
|
|
129
117
|
ot = @table.merge( hash )
|
130
|
-
ot['accept'].
|
131
|
-
ot['cookie-flavor'].
|
118
|
+
expect( ot['accept'] ).to eq( 'thing' )
|
119
|
+
expect( ot['cookie-flavor'] ).to eq( 'peanut butter' )
|
132
120
|
end
|
133
121
|
|
134
122
|
|
@@ -141,9 +129,9 @@ describe Mongrel2::Table do
|
|
141
129
|
newtable[:foom] << " and another string"
|
142
130
|
newtable[:frong][3].replace( "mississipi" )
|
143
131
|
|
144
|
-
@table.
|
145
|
-
@table[:foom].
|
146
|
-
@table[:frong][3].
|
132
|
+
expect( @table ).to_not include( 'idkfa' )
|
133
|
+
expect( @table[:foom] ).to eq( 'a string' )
|
134
|
+
expect( @table[:frong][3] ).to eq( 'moe' )
|
147
135
|
end
|
148
136
|
|
149
137
|
|
@@ -153,7 +141,7 @@ describe Mongrel2::Table do
|
|
153
141
|
@table['porntipsguzzardo'] = 'cha-ching'
|
154
142
|
|
155
143
|
results = @table.values_at( :idspispopd, 'PornTipsGuzzARDO' )
|
156
|
-
results.
|
144
|
+
expect( results ).to eq( [ 'ghosty', 'cha-ching' ] )
|
157
145
|
end
|
158
146
|
|
159
147
|
|
@@ -168,14 +156,14 @@ describe Mongrel2::Table do
|
|
168
156
|
values << [ header, value ]
|
169
157
|
end
|
170
158
|
|
171
|
-
values.flatten.
|
172
|
-
values.transpose[0].
|
173
|
-
values.transpose[1].
|
159
|
+
expect( values.flatten ).to have(8).members
|
160
|
+
expect( values.transpose[0] ).to include( 'Thai-Food', 'With-Absinthe', 'A-Number-Of-Some-Sort' )
|
161
|
+
expect( values.transpose[1] ).to include( 'normally good', 'seldom hot enough', 'questionable', '2' )
|
174
162
|
end
|
175
163
|
|
176
164
|
|
177
165
|
it "can yield an Enumerator for its header iterator" do
|
178
|
-
@table.each_header.
|
166
|
+
expect( @table.each_header ).to be_a( Enumerator )
|
179
167
|
end
|
180
168
|
end
|
181
169
|
|