strelka 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ChangeLog +156 -9
  4. data/History.rdoc +15 -0
  5. data/IDEAS.rdoc +17 -1
  6. data/MILESTONES.rdoc +1 -1
  7. data/Manifest.txt +10 -2
  8. data/Plugins.rdoc +4 -4
  9. data/README.rdoc +3 -3
  10. data/Rakefile +5 -4
  11. data/bin/strelka +19 -10
  12. data/contrib/hoetemplate/data/project/apps/file_name_app +1 -0
  13. data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
  14. data/examples/apps/hello-world +1 -0
  15. data/examples/apps/ws-chat +69 -0
  16. data/examples/apps/ws-echo +61 -0
  17. data/examples/gen-config.rb +6 -5
  18. data/lib/strelka/app/auth.rb +2 -2
  19. data/lib/strelka/app/errors.rb +1 -1
  20. data/lib/strelka/app/filters.rb +3 -2
  21. data/lib/strelka/app/negotiation.rb +2 -2
  22. data/lib/strelka/app/parameters.rb +1 -2
  23. data/lib/strelka/app/restresources.rb +3 -2
  24. data/lib/strelka/app/routing.rb +1 -1
  25. data/lib/strelka/app/sessions.rb +2 -2
  26. data/lib/strelka/app/templating.rb +7 -3
  27. data/lib/strelka/app.rb +5 -145
  28. data/lib/strelka/behavior/plugin.rb +4 -4
  29. data/lib/strelka/discovery.rb +211 -0
  30. data/lib/strelka/httprequest.rb +1 -0
  31. data/lib/strelka/httpresponse/negotiation.rb +7 -1
  32. data/lib/strelka/mixins.rb +4 -1
  33. data/lib/strelka/paramvalidator.rb +1 -1
  34. data/lib/strelka/plugins.rb +8 -6
  35. data/lib/strelka/websocketserver/routing.rb +116 -0
  36. data/lib/strelka/websocketserver.rb +147 -0
  37. data/lib/strelka.rb +5 -4
  38. data/spec/{lib/constants.rb → constants.rb} +3 -2
  39. data/spec/{lib/helpers.rb → helpers.rb} +15 -14
  40. data/spec/strelka/app/auth_spec.rb +145 -142
  41. data/spec/strelka/app/errors_spec.rb +20 -26
  42. data/spec/strelka/app/filters_spec.rb +67 -54
  43. data/spec/strelka/app/negotiation_spec.rb +8 -14
  44. data/spec/strelka/app/parameters_spec.rb +23 -29
  45. data/spec/strelka/app/restresources_spec.rb +98 -100
  46. data/spec/strelka/app/routing_spec.rb +57 -57
  47. data/spec/strelka/app/sessions_spec.rb +11 -17
  48. data/spec/strelka/app/templating_spec.rb +36 -40
  49. data/spec/strelka/app_spec.rb +48 -147
  50. data/spec/strelka/authprovider/basic_spec.rb +5 -11
  51. data/spec/strelka/authprovider/hostaccess_spec.rb +9 -15
  52. data/spec/strelka/authprovider_spec.rb +3 -9
  53. data/spec/strelka/cookie_spec.rb +32 -38
  54. data/spec/strelka/cookieset_spec.rb +31 -37
  55. data/spec/strelka/discovery_spec.rb +144 -0
  56. data/spec/strelka/exceptions_spec.rb +2 -8
  57. data/spec/strelka/httprequest/acceptparams_spec.rb +74 -83
  58. data/spec/strelka/httprequest/auth_spec.rb +5 -15
  59. data/spec/strelka/httprequest/negotiation_spec.rb +93 -103
  60. data/spec/strelka/httprequest/session_spec.rb +12 -22
  61. data/spec/strelka/httprequest_spec.rb +1 -7
  62. data/spec/strelka/httpresponse/negotiation_spec.rb +84 -76
  63. data/spec/strelka/httpresponse/session_spec.rb +25 -35
  64. data/spec/strelka/httpresponse_spec.rb +20 -26
  65. data/spec/strelka/mixins_spec.rb +66 -61
  66. data/spec/strelka/multipartparser_spec.rb +31 -37
  67. data/spec/strelka/paramvalidator_spec.rb +389 -373
  68. data/spec/strelka/plugins_spec.rb +17 -23
  69. data/spec/strelka/router/default_spec.rb +32 -38
  70. data/spec/strelka/router/exclusive_spec.rb +28 -34
  71. data/spec/strelka/router_spec.rb +2 -8
  72. data/spec/strelka/session/db_spec.rb +17 -15
  73. data/spec/strelka/session/default_spec.rb +22 -28
  74. data/spec/strelka/session_spec.rb +3 -9
  75. data/spec/strelka/websocketserver/routing_spec.rb +119 -0
  76. data/spec/strelka/websocketserver_spec.rb +149 -0
  77. data/spec/strelka_spec.rb +11 -13
  78. data.tar.gz.sig +3 -3
  79. metadata +22 -14
  80. metadata.gz.sig +0 -0
@@ -1,20 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  #encoding: utf-8
3
3
 
4
- BEGIN {
5
- require 'pathname'
6
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
7
-
8
- libdir = basedir + "lib"
9
-
10
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
- }
4
+ require_relative '../../helpers'
13
5
 
14
6
  require 'rspec'
15
7
 
16
- require 'spec/lib/helpers'
17
-
18
8
  require 'strelka'
19
9
  require 'strelka/httprequest/negotiation'
20
10
  require 'strelka/httpresponse/negotiation'
@@ -48,7 +38,7 @@ describe Strelka::HTTPResponse::Negotiation do
48
38
  @res.puts( "FOOM!" )
49
39
  @res.content_type = 'text/plain'
50
40
  @res.charset = Encoding::UTF_8
51
- @res.to_s.should include(
41
+ expect( @res.to_s ).to include(
52
42
  'HTTP/1.1 200 OK',
53
43
  'Content-Length: 6',
54
44
  'Content-Type: text/plain; charset=UTF-8',
@@ -67,9 +57,9 @@ describe Strelka::HTTPResponse::Negotiation do
67
57
  @res.for( 'application/x-yaml' ) { { 'a' => "YAML dump" } }
68
58
 
69
59
  @res.negotiated_body.rewind
70
- @res.negotiated_body.read.should == "---\na: YAML dump\n"
71
- @res.content_type.should == "application/x-yaml"
72
- @res.header_data.should =~ /accept(?!-)/i
60
+ expect( @res.negotiated_body.read ).to eq( "---\na: YAML dump\n" )
61
+ expect( @res.content_type ).to eq( "application/x-yaml" )
62
+ expect( @res.header_data ).to match( /accept(?!-)/i )
73
63
  end
74
64
 
75
65
  it "can provide a single block for bodies of several different mediatypes" do
@@ -80,10 +70,11 @@ describe Strelka::HTTPResponse::Negotiation do
80
70
  end
81
71
 
82
72
  @res.negotiated_body.rewind
83
- @res.negotiated_body.read.should == "{\"uuid\":\"fc85e35b-c9c3-4675-a882-25bf98d11e1b\"," +
84
- "\"name\":\"Harlot's Garden\"}"
85
- @res.content_type.should == "application/json"
86
- @res.header_data.should =~ /accept(?!-)/i
73
+ expect( @res.negotiated_body.read ).
74
+ to eq( "{\"uuid\":\"fc85e35b-c9c3-4675-a882-25bf98d11e1b\"," +
75
+ "\"name\":\"Harlot's Garden\"}" )
76
+ expect( @res.content_type ).to eq( "application/json" )
77
+ expect( @res.header_data ).to match( /accept(?!-)/i )
87
78
  end
88
79
 
89
80
  it "can provide a block for bodies of several different symbolic mediatypes" do
@@ -94,10 +85,11 @@ describe Strelka::HTTPResponse::Negotiation do
94
85
  end
95
86
 
96
87
  @res.negotiated_body.rewind
97
- @res.negotiated_body.read.should == "{\"uuid\":\"fc85e35b-c9c3-4675-a882-25bf98d11e1b\"," +
98
- "\"name\":\"Harlot's Garden\"}"
99
- @res.content_type.should == "application/json"
100
- @res.header_data.should =~ /accept(?!-)/i
88
+ expect( @res.negotiated_body.read ).
89
+ to eq( "{\"uuid\":\"fc85e35b-c9c3-4675-a882-25bf98d11e1b\"," +
90
+ "\"name\":\"Harlot's Garden\"}" )
91
+ expect( @res.content_type ).to eq( "application/json" )
92
+ expect( @res.header_data ).to match( /accept(?!-)/i )
101
93
  end
102
94
 
103
95
  it "raises an exception if given a block for an unknown symbolic mediatype" do
@@ -106,6 +98,22 @@ describe Strelka::HTTPResponse::Negotiation do
106
98
  }.to raise_error( StandardError, /no known mimetype/i )
107
99
  end
108
100
 
101
+ it "treat exceptions raised from the block as failed transformations" do
102
+ @req.headers.accept = 'application/json, text/plain; q=0.9'
103
+
104
+ @res.for( :json ) do
105
+ raise "Oops! I fail at JSON!"
106
+ end
107
+ @res.for( :text ) do
108
+ "But I can do plain-text all day long!"
109
+ end
110
+
111
+ @res.negotiated_body.rewind
112
+ expect( @res.negotiated_body.read ).to eq( "But I can do plain-text all day long!" )
113
+ expect( @res.content_type ).to eq( 'text/plain' )
114
+ expect( @res.header_data ).to match( /accept(?!-)/i )
115
+ end
116
+
109
117
  end
110
118
 
111
119
 
@@ -117,8 +125,8 @@ describe Strelka::HTTPResponse::Negotiation do
117
125
  @res.body = File.read( __FILE__, encoding: 'iso-8859-5' )
118
126
  @res.content_type = 'text/plain'
119
127
 
120
- @res.negotiated_body.external_encoding.should == Encoding::KOI8_R
121
- @res.header_data.should =~ /accept-charset(?!-)/i
128
+ expect( @res.negotiated_body.external_encoding ).to eq( Encoding::KOI8_R )
129
+ expect( @res.header_data ).to match( /accept-charset(?!-)/i )
122
130
  end
123
131
 
124
132
  it "transcodes String entity bodies if the charset is not acceptable" do
@@ -127,8 +135,8 @@ describe Strelka::HTTPResponse::Negotiation do
127
135
  @res.body = File.read( __FILE__, encoding: 'iso-8859-5' )
128
136
  @res.content_type = 'application/json'
129
137
 
130
- @res.negotiated_body.external_encoding.should == Encoding::UTF_8
131
- @res.header_data.should =~ /accept-charset(?!-)/i
138
+ expect( @res.negotiated_body.external_encoding ).to eq( Encoding::UTF_8 )
139
+ expect( @res.header_data ).to match( /accept-charset(?!-)/i )
132
140
  end
133
141
 
134
142
  it "transcodes File entity bodies if the charset is not acceptable" do
@@ -138,8 +146,8 @@ describe Strelka::HTTPResponse::Negotiation do
138
146
  @res.body = File.open( __FILE__, 'r:iso-8859-5' )
139
147
  @res.content_type = 'text/plain'
140
148
 
141
- @res.negotiated_body.read.encoding.should == Encoding::KOI8_R
142
- @res.header_data.should =~ /accept-charset(?!-)/i
149
+ expect( @res.negotiated_body.read.encoding ).to eq( Encoding::KOI8_R )
150
+ expect( @res.header_data ).to match( /accept-charset(?!-)/i )
143
151
  end
144
152
  end
145
153
 
@@ -159,9 +167,9 @@ describe Strelka::HTTPResponse::Negotiation do
159
167
  @res.for_language( :sl ) { "Slovenian translation" }
160
168
 
161
169
  @res.negotiated_body.rewind
162
- @res.negotiated_body.read.should == "German translation"
163
- @res.languages.should == ["de"]
164
- @res.header_data.should =~ /accept-language/i
170
+ expect( @res.negotiated_body.read ).to eq( "German translation" )
171
+ expect( @res.languages ).to eq( ["de"] )
172
+ expect( @res.header_data ).to match( /accept-language/i )
165
173
  end
166
174
 
167
175
  it "can provide blocks for bodies of several different languages without setting a " +
@@ -175,9 +183,9 @@ describe Strelka::HTTPResponse::Negotiation do
175
183
  @res.for_language( :sl ) { "Slovenian translation" }
176
184
 
177
185
  @res.negotiated_body.rewind
178
- @res.negotiated_body.read.should == "German translation"
179
- @res.languages.should == ["de"]
180
- @res.header_data.should =~ /accept-language/i
186
+ expect( @res.negotiated_body.read ).to eq( "German translation" )
187
+ expect( @res.languages ).to eq( ["de"] )
188
+ expect( @res.header_data ).to match( /accept-language/i )
181
189
  end
182
190
 
183
191
  it "can provide a single block for bodies of several different languages" do
@@ -195,9 +203,9 @@ describe Strelka::HTTPResponse::Negotiation do
195
203
  end
196
204
 
197
205
  @res.negotiated_body.rewind
198
- @res.negotiated_body.read.should == "Portuguese translation"
199
- @res.languages.should == ["pt"]
200
- @res.header_data.should =~ /accept-language/i
206
+ expect( @res.negotiated_body.read ).to eq( "Portuguese translation" )
207
+ expect( @res.languages ).to eq( ["pt"] )
208
+ expect( @res.header_data ).to match( /accept-language/i )
201
209
  end
202
210
 
203
211
  it "calls the first block for requests with no accept-language header" do
@@ -210,9 +218,9 @@ describe Strelka::HTTPResponse::Negotiation do
210
218
  @res.for_language( :sl ) { "Slovenian translation" }
211
219
 
212
220
  @res.negotiated_body.rewind
213
- @res.negotiated_body.read.should == "English translation"
214
- @res.languages.should == ["en"]
215
- @res.header_data.should =~ /accept-language/i
221
+ expect( @res.negotiated_body.read ).to eq( "English translation" )
222
+ expect( @res.languages ).to eq( ["en"] )
223
+ expect( @res.header_data ).to match( /accept-language/i )
216
224
  end
217
225
  end
218
226
 
@@ -229,10 +237,10 @@ describe Strelka::HTTPResponse::Negotiation do
229
237
  @res.for_encoding( :gzip ) { @res.body << " (gzipped)" }
230
238
 
231
239
  @res.negotiated_body.rewind
232
- @res.negotiated_body.read.should == "the text body (gzipped)"
233
- @res.encodings.should include( "gzip" )
234
- @res.header_data.should =~ /accept-encoding/i
235
- @res.header_data.should_not =~ /identity/i
240
+ expect( @res.negotiated_body.read ).to eq( "the text body (gzipped)" )
241
+ expect( @res.encodings ).to include( "gzip" )
242
+ expect( @res.header_data ).to match( /accept-encoding/i )
243
+ expect( @res.header_data ).to_not match( /identity/i )
236
244
  end
237
245
 
238
246
  it "chooses the content coding with the highest qvalue" do
@@ -245,10 +253,10 @@ describe Strelka::HTTPResponse::Negotiation do
245
253
  @res.for_encoding( :gzip ) { @res.body << " (gzipped)" }
246
254
 
247
255
  @res.negotiated_body.rewind
248
- @res.negotiated_body.read.should == "the text body (deflated)"
249
- @res.encodings.should include( "deflate" )
250
- @res.header_data.should =~ /accept-encoding/i
251
- @res.header_data.should_not =~ /identity/i
256
+ expect( @res.negotiated_body.read ).to eq( "the text body (deflated)" )
257
+ expect( @res.encodings ).to include( "deflate" )
258
+ expect( @res.header_data ).to match( /accept-encoding/i )
259
+ expect( @res.header_data ).to_not match( /identity/i )
252
260
  end
253
261
 
254
262
  end
@@ -261,14 +269,14 @@ describe Strelka::HTTPResponse::Negotiation do
261
269
  @req.headers.accept = 'application/x-yaml, application/json; q=0.7'
262
270
  @res.content_type = 'application/json'
263
271
 
264
- @res.should have_acceptable_content_type()
272
+ expect( @res ).to have_acceptable_content_type
265
273
  end
266
274
 
267
275
  it "knows that it is acceptable if its request doesn't have accepted types" do
268
276
  @req.headers.delete( :accept )
269
277
  @res.content_type = 'application/x-ruby-marshalled'
270
278
 
271
- @res.should have_acceptable_content_type()
279
+ expect( @res ).to have_acceptable_content_type
272
280
  end
273
281
 
274
282
  it "knows that it is acceptable if it doesn't have an originating request" do
@@ -276,7 +284,7 @@ describe Strelka::HTTPResponse::Negotiation do
276
284
  res.extend( Strelka::HTTPResponse::Negotiation )
277
285
  res.content_type = 'application/x-ruby-marshalled'
278
286
 
279
- res.should have_acceptable_content_type()
287
+ expect( res ).to have_acceptable_content_type
280
288
  end
281
289
 
282
290
  it "knows that it is not acceptable if its content_type isn't in the list of " +
@@ -284,7 +292,7 @@ describe Strelka::HTTPResponse::Negotiation do
284
292
  @req.headers.accept = 'application/x-yaml, application/json; q=0.7'
285
293
  @res.content_type = 'application/x-ruby-marshalled'
286
294
 
287
- @res.should_not have_acceptable_content_type()
295
+ expect( @res ).to_not have_acceptable_content_type
288
296
  end
289
297
 
290
298
  end
@@ -297,20 +305,20 @@ describe Strelka::HTTPResponse::Negotiation do
297
305
  @req.headers.accept_charset = 'iso-8859-5, utf-8;q=0.8'
298
306
  @res.charset = 'iso-8859-5'
299
307
 
300
- @res.should have_acceptable_charset()
308
+ expect( @res ).to have_acceptable_charset()
301
309
  end
302
310
 
303
311
  it "knows that it is acceptable if its request doesn't have accepted types" do
304
312
  @req.headers.delete( :accept_charset )
305
313
  @res.charset = 'koi8-u'
306
- @res.should have_acceptable_charset()
314
+ expect( @res ).to have_acceptable_charset()
307
315
  end
308
316
 
309
317
  it "knows that it is acceptable if it doesn't have an originating request" do
310
318
  res = Strelka::HTTPResponse.new( 'appid', 88 )
311
319
  res.charset = 'iso8859-15'
312
320
 
313
- res.should have_acceptable_charset()
321
+ expect( res ).to have_acceptable_charset()
314
322
  end
315
323
 
316
324
  it "knows that it is acceptable if its explicit charset is set to ascii-8bit" do
@@ -318,7 +326,7 @@ describe Strelka::HTTPResponse::Negotiation do
318
326
  @res.content_type = 'image/jpeg'
319
327
  @res.charset = Encoding::ASCII_8BIT
320
328
 
321
- @res.should have_acceptable_charset()
329
+ expect( @res ).to have_acceptable_charset()
322
330
  end
323
331
 
324
332
  it "knows that it is acceptable if no charset can be derived, but the list of " +
@@ -327,7 +335,7 @@ describe Strelka::HTTPResponse::Negotiation do
327
335
  @res.content_type = 'text/plain'
328
336
  @res.body = "some stuff".force_encoding( Encoding::ASCII_8BIT )
329
337
 
330
- @res.should have_acceptable_charset()
338
+ expect( @res ).to have_acceptable_charset()
331
339
  end
332
340
 
333
341
  it "knows that it is not acceptable if no charset can be derived, the content is a " +
@@ -336,7 +344,7 @@ describe Strelka::HTTPResponse::Negotiation do
336
344
  @res.content_type = 'text/plain'
337
345
  @res.body = "some stuff".force_encoding( Encoding::ASCII_8BIT )
338
346
 
339
- @res.should_not have_acceptable_charset()
347
+ expect( @res ).to_not have_acceptable_charset()
340
348
  end
341
349
 
342
350
  it "knows that it is not acceptable if its explicit charset isn't in the list of " +
@@ -344,7 +352,7 @@ describe Strelka::HTTPResponse::Negotiation do
344
352
  @req.headers.accept_charset = 'iso-8859-5, utf-8;q=0.8'
345
353
  @res.charset = 'sjis'
346
354
 
347
- @res.should_not have_acceptable_charset()
355
+ expect( @res ).to_not have_acceptable_charset()
348
356
  end
349
357
 
350
358
  it "knows that it is not acceptable if the charset in its content-type header isn't in " +
@@ -352,7 +360,7 @@ describe Strelka::HTTPResponse::Negotiation do
352
360
  @req.headers.accept_charset = 'iso-8859-5, utf-8;q=0.8'
353
361
  @res.content_type = 'text/plain; charset=sjis'
354
362
 
355
- @res.should_not have_acceptable_charset()
363
+ expect( @res ).to_not have_acceptable_charset()
356
364
  end
357
365
 
358
366
  it "knows that it is not acceptable if the charset derived from its entity body isn't in " +
@@ -361,7 +369,7 @@ describe Strelka::HTTPResponse::Negotiation do
361
369
  @res.content_type = 'text/plain'
362
370
  @res.body = File.open( __FILE__, 'r:iso8859-5' )
363
371
 
364
- @res.should_not have_acceptable_charset()
372
+ expect( @res ).to_not have_acceptable_charset()
365
373
  end
366
374
 
367
375
  end
@@ -374,7 +382,7 @@ describe Strelka::HTTPResponse::Negotiation do
374
382
  @req.headers.accept_language = 'en-gb, en; q=0.7, ja;q=0.2'
375
383
  @res.languages << 'ja'
376
384
 
377
- @res.should have_acceptable_language()
385
+ expect( @res ).to have_acceptable_language()
378
386
  end
379
387
 
380
388
  it "knows that it is acceptable if all of its multiple languages are in the list of " +
@@ -382,7 +390,7 @@ describe Strelka::HTTPResponse::Negotiation do
382
390
  @req.headers.accept_language = 'en-gb, en; q=0.7, ja;q=0.2'
383
391
  @res.languages << 'ja' << 'en-us'
384
392
 
385
- @res.should have_acceptable_language()
393
+ expect( @res ).to have_acceptable_language()
386
394
  end
387
395
 
388
396
  # I'm not sure if this is what RFC1616 means. It might be that *all* of its languages
@@ -392,7 +400,7 @@ describe Strelka::HTTPResponse::Negotiation do
392
400
  @req.headers.accept_language = 'en-gb, en; q=0.7, ja;q=0.2'
393
401
  @res.languages << 'pt' << 'en'
394
402
 
395
- @res.should have_acceptable_language()
403
+ expect( @res ).to have_acceptable_language()
396
404
  end
397
405
 
398
406
  it "knows that it is acceptable if it has a body but doesn't have a language set" do
@@ -400,14 +408,14 @@ describe Strelka::HTTPResponse::Negotiation do
400
408
  @res.languages.clear
401
409
  @res.puts( "Some content in an unspecified language." )
402
410
 
403
- @res.should have_acceptable_language()
411
+ expect( @res ).to have_acceptable_language()
404
412
  end
405
413
 
406
414
  it "knows that it is acceptable if it has no body yet" do
407
415
  @req.headers.accept_language = 'en-gb, en; q=0.7, ja;q=0.2'
408
416
  @res.languages.clear
409
417
 
410
- @res.should have_acceptable_language()
418
+ expect( @res ).to have_acceptable_language()
411
419
  end
412
420
 
413
421
  it "knows that it is acceptable if it doesn't have an originating request" do
@@ -415,7 +423,7 @@ describe Strelka::HTTPResponse::Negotiation do
415
423
  res.extend( Strelka::HTTPResponse::Negotiation )
416
424
  res.languages << 'kh'
417
425
 
418
- res.should have_acceptable_language()
426
+ expect( res ).to have_acceptable_language()
419
427
  end
420
428
 
421
429
  it "knows that it is not acceptable if it has a single language that isn't in the " +
@@ -423,7 +431,7 @@ describe Strelka::HTTPResponse::Negotiation do
423
431
  @req.headers.accept_language = 'en-gb, en; q=0.7, ja;q=0.2'
424
432
  @res.languages << 'pt'
425
433
 
426
- @res.should_not have_acceptable_language()
434
+ expect( @res ).to_not have_acceptable_language()
427
435
  end
428
436
 
429
437
  it "knows that it is not acceptable if it has multiple languages, none of which are " +
@@ -431,7 +439,7 @@ describe Strelka::HTTPResponse::Negotiation do
431
439
  @req.headers.accept_language = 'en-gb, en; q=0.7, ja;q=0.2'
432
440
  @res.languages << 'pt-br' << 'fr-ca'
433
441
 
434
- @res.should_not have_acceptable_language()
442
+ expect( @res ).to_not have_acceptable_language()
435
443
  end
436
444
 
437
445
  end
@@ -444,7 +452,7 @@ describe Strelka::HTTPResponse::Negotiation do
444
452
  @req.headers.accept_encoding = 'gzip;q=1.0, identity; q=0.5, *;q=0'
445
453
  @res.encodings << 'gzip'
446
454
 
447
- @res.should have_acceptable_encoding()
455
+ expect( @res ).to have_acceptable_encoding()
448
456
  end
449
457
 
450
458
  it "knows that it is acceptable if all of its content codings are in the list of accepted " +
@@ -452,7 +460,7 @@ describe Strelka::HTTPResponse::Negotiation do
452
460
  @req.headers.accept_encoding = 'gzip;q=1.0, frobnify;q=0.9, identity; q=0.5, *;q=0'
453
461
  @res.encodings << 'gzip' << 'frobnify'
454
462
 
455
- @res.should have_acceptable_encoding()
463
+ expect( @res ).to have_acceptable_encoding()
456
464
  end
457
465
 
458
466
  it "knows that it is not acceptable if one of its content codings is not in the list " +
@@ -460,7 +468,7 @@ describe Strelka::HTTPResponse::Negotiation do
460
468
  @req.headers.accept_encoding = 'gzip;q=1.0, identity; q=0.5, *;q=0'
461
469
  @res.encodings << 'gzip' << 'frobnify'
462
470
 
463
- @res.should_not have_acceptable_encoding()
471
+ expect( @res ).to_not have_acceptable_encoding()
464
472
  end
465
473
 
466
474
  it "knows that it is not acceptable if it doesn't have any explicit content codings " +
@@ -468,7 +476,7 @@ describe Strelka::HTTPResponse::Negotiation do
468
476
  @req.headers.accept_encoding = 'gzip;q=1.0, identity; q=0'
469
477
  @res.encodings.clear
470
478
 
471
- @res.should_not have_acceptable_encoding()
479
+ expect( @res ).to_not have_acceptable_encoding()
472
480
  end
473
481
 
474
482
  it "knows that it is not acceptable if it doesn't have any explicit content codings " +
@@ -476,7 +484,7 @@ describe Strelka::HTTPResponse::Negotiation do
476
484
  @req.headers.accept_encoding = 'gzip;q=1.0, identity; q=0'
477
485
  @res.encodings.clear
478
486
 
479
- @res.should_not have_acceptable_encoding()
487
+ expect( @res ).to_not have_acceptable_encoding()
480
488
  end
481
489
 
482
490
  it "knows that it is not acceptable if it doesn't have any explicit content codings, " +
@@ -484,7 +492,7 @@ describe Strelka::HTTPResponse::Negotiation do
484
492
  @req.headers.accept_encoding = 'gzip;q=1.0, *;q=0'
485
493
  @res.encodings.clear
486
494
 
487
- @res.should_not have_acceptable_encoding()
495
+ expect( @res ).to_not have_acceptable_encoding()
488
496
  end
489
497
 
490
498
  end
@@ -1,20 +1,10 @@
1
1
  # -*- rspec -*-
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
 
4
- BEGIN {
5
- require 'pathname'
6
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
7
-
8
- libdir = basedir + "lib"
9
-
10
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
- }
4
+ require_relative '../../helpers'
13
5
 
14
6
  require 'rspec'
15
7
 
16
- require 'spec/lib/helpers'
17
-
18
8
  require 'strelka'
19
9
  require 'strelka/app/sessions'
20
10
  require 'strelka/httprequest/session'
@@ -51,34 +41,34 @@ describe Strelka::HTTPResponse::Session, "-extended response" do
51
41
 
52
42
 
53
43
  it "has a session_namespace attribute" do
54
- @res.should respond_to( :session_namespace )
44
+ expect( @res ).to respond_to( :session_namespace )
55
45
  end
56
46
 
57
47
  it "sets its request's session when its session is set" do
58
48
  @res.session = Strelka::Session.create( :default )
59
49
  pending "not sure if it should do this or not" do
60
- @req.session.should be( @res.session )
50
+ expect( @req.session ).to be( @res.session )
61
51
  end
62
52
  end
63
53
 
64
54
  context "for a request with no session ID" do
65
55
 
66
56
  it "knows that it doesn't have a session" do
67
- @res.should_not have_session()
57
+ expect( @res ).to_not have_session()
68
58
  end
69
59
 
70
60
  it "doesn't load the session when the session namespace is set" do
71
61
  @res.session_namespace = 'an_appid'
72
- @res.should_not have_session()
62
+ expect( @res ).to_not have_session()
73
63
  end
74
64
 
75
65
  it "creates a new session as soon as it's accessed" do
76
- @res.session.should be_a( Strelka::Session::Default )
66
+ expect( @res.session ).to be_a( Strelka::Session::Default )
77
67
  end
78
68
 
79
69
  it "sets its session's namespace when it loads if the session_namespace is set" do
80
70
  @res.session_namespace = 'an_appid'
81
- @res.session.namespace.should == :an_appid
71
+ expect( @res.session.namespace ).to eq( :an_appid )
82
72
  end
83
73
 
84
74
 
@@ -90,16 +80,16 @@ describe Strelka::HTTPResponse::Session, "-extended response" do
90
80
  end
91
81
 
92
82
  it "knows that it has a session" do
93
- @res.should have_session()
83
+ expect( @res ).to have_session()
94
84
  end
95
85
 
96
86
  it "copies the session from its request when accessed" do
97
- @res.session.should be( @session )
87
+ expect( @res.session ).to be( @session )
98
88
  end
99
89
 
100
90
  it "sets the session's namespace when its session_namespace is set" do
101
91
  @res.session_namespace = 'the_appid'
102
- @res.session.namespace.should == :the_appid
92
+ expect( @res.session.namespace ).to eq( :the_appid )
103
93
  end
104
94
 
105
95
  end
@@ -116,7 +106,7 @@ describe Strelka::HTTPResponse::Session, "-extended response" do
116
106
  end
117
107
 
118
108
  it "knows that it doesn't have a session unless the ID exists" do
119
- @res.should_not have_session()
109
+ expect( @res ).to_not have_session()
120
110
  end
121
111
 
122
112
 
@@ -127,49 +117,49 @@ describe Strelka::HTTPResponse::Session, "-extended response" do
127
117
  end
128
118
 
129
119
  it "knows that it has a session" do
130
- @res.should have_session()
120
+ expect( @res ).to have_session()
131
121
  end
132
122
 
133
123
  it "knows that its session has been loaded if it has one" do
134
124
  @res.session
135
- @res.session_loaded?.should be_true()
125
+ expect( @res.session_loaded? ).to be_true()
136
126
  end
137
127
 
138
128
  it "knows that its session has been loaded if its request has one" do
139
129
  @res.request.session
140
- @res.session_loaded?.should be_true()
130
+ expect( @res.session_loaded? ).to be_true()
141
131
  end
142
132
 
143
133
  it "knows that its session hasn't been loaded if neither its request not itself has one" do
144
- @res.session_loaded?.should be_false()
134
+ expect( @res.session_loaded? ).to be_false()
145
135
  end
146
136
 
147
137
  it "saves the session via itself if it was loaded" do
148
- @res.cookies.should_not include( @cookie_name )
138
+ expect( @res.cookies ).to_not include( @cookie_name )
149
139
  @res.session
150
140
  @res.save_session
151
- @res.cookies[ @cookie_name ].value.should == @sess_id
141
+ expect( @res.cookies[ @cookie_name ].value ).to eq( @sess_id )
152
142
  end
153
143
 
154
144
  it "doesn't save the session via itself if it wasn't loaded" do
155
- @res.cookies.should_not include( @cookie_name )
145
+ expect( @res.cookies ).to_not include( @cookie_name )
156
146
  @res.save_session
157
- @res.cookies.should be_empty()
147
+ expect( @res.cookies ).to be_empty()
158
148
  end
159
149
 
160
150
  it "destroys the session via itself if it was loaded" do
161
- @res.cookies.should_not include( @cookie_name )
151
+ expect( @res.cookies ).to_not include( @cookie_name )
162
152
  @res.session
163
153
  @res.destroy_session
164
- @res.cookies[ @cookie_name ].value.should == @sess_id
165
- @res.cookies[ @cookie_name ].expires.should < Time.now
154
+ expect( @res.cookies[ @cookie_name ].value ).to eq( @sess_id )
155
+ expect( @res.cookies[ @cookie_name ].expires ).to be < Time.now
166
156
  end
167
157
 
168
158
  it "destroys the session via itself even if it wasn't loaded" do
169
- @res.cookies.should_not include( @cookie_name )
159
+ expect( @res.cookies ).to_not include( @cookie_name )
170
160
  @res.destroy_session
171
- @res.cookies[ @cookie_name ].value.should == @sess_id
172
- @res.cookies[ @cookie_name ].expires.should < Time.now
161
+ expect( @res.cookies[ @cookie_name ].value ).to eq( @sess_id )
162
+ expect( @res.cookies[ @cookie_name ].expires ).to be < Time.now
173
163
  end
174
164
 
175
165
  end