strelka 0.6.0 → 0.7.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.
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
@@ -2,20 +2,10 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
8
-
9
- libdir = basedir + "lib"
10
-
11
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
12
- $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
13
- }
5
+ require_relative '../../helpers'
14
6
 
15
7
  require 'rspec'
16
8
 
17
- require 'spec/lib/helpers'
18
-
19
9
  require 'strelka'
20
10
  require 'strelka/httprequest/negotiation'
21
11
  require 'strelka/httpresponse/negotiation'
@@ -48,53 +38,53 @@ describe Strelka::HTTPRequest::Negotiation do
48
38
  it "know what content-types are accepted by the client" do
49
39
  @req.headers.accept = 'application/x-yaml, application/json; q=0.2, text/xml; q=0.75'
50
40
 
51
- @req.accepted_types.should have(3).members
52
- @req.accepted_types[0].mediatype.should == 'application/x-yaml'
53
- @req.accepted_types[0].qvalue.should == 1.0
54
- @req.accepted_types[1].mediatype.should == 'application/json'
55
- @req.accepted_types[1].qvalue.should == 0.2
56
- @req.accepted_types[2].mediatype.should == 'text/xml'
57
- @req.accepted_types[2].qvalue.should == 0.75
41
+ expect( @req.accepted_types ).to have(3).members
42
+ expect( @req.accepted_types[0].mediatype ).to eq( 'application/x-yaml' )
43
+ expect( @req.accepted_types[0].qvalue ).to eq( 1.0 )
44
+ expect( @req.accepted_types[1].mediatype ).to eq( 'application/json' )
45
+ expect( @req.accepted_types[1].qvalue ).to eq( 0.2 )
46
+ expect( @req.accepted_types[2].mediatype ).to eq( 'text/xml' )
47
+ expect( @req.accepted_types[2].qvalue ).to eq( 0.75 )
58
48
  end
59
49
 
60
50
  it "knows what mimetypes are acceptable responses" do
61
51
  @req.headers.accept = 'text/html, text/plain; q=0.5, image/*;q=0.1'
62
52
 
63
- @req.accepts?( 'text/html' ).should be_true()
64
- @req.accepts?( 'text/plain' ).should be_true()
65
- @req.accepts?( 'text/ascii' ).should be_false()
66
- @req.accepts?( 'image/png' ).should be_true()
67
- @req.accepts?( 'application/x-yaml' ).should be_false()
53
+ expect( @req.accepts?( 'text/html' ) ).to be_true()
54
+ expect( @req.accepts?( 'text/plain' ) ).to be_true()
55
+ expect( @req.accepts?( 'text/ascii' ) ).to be_false()
56
+ expect( @req.accepts?( 'image/png' ) ).to be_true()
57
+ expect( @req.accepts?( 'application/x-yaml' ) ).to be_false()
68
58
  end
69
59
 
70
60
  it "knows what mimetypes are explicitly acceptable responses" do
71
61
  @req.headers.accept = 'text/html, text/plain; q=0.5, image/*;q=0.1, */*'
72
62
 
73
- @req.explicitly_accepts?( 'text/html' ).should be_true()
74
- @req.explicitly_accepts?( 'text/plain' ).should be_true()
75
- @req.explicitly_accepts?( 'text/ascii' ).should be_false()
76
- @req.explicitly_accepts?( 'image/png' ).should be_false()
77
- @req.explicitly_accepts?( 'application/x-yaml' ).should be_false()
63
+ expect( @req.explicitly_accepts?( 'text/html' ) ).to be_true()
64
+ expect( @req.explicitly_accepts?( 'text/plain' ) ).to be_true()
65
+ expect( @req.explicitly_accepts?( 'text/ascii' ) ).to be_false()
66
+ expect( @req.explicitly_accepts?( 'image/png' ) ).to be_false()
67
+ expect( @req.explicitly_accepts?( 'application/x-yaml' ) ).to be_false()
78
68
  end
79
69
 
80
70
  it "accepts anything if the client doesn't provide an Accept header" do
81
71
  @req.headers.delete( :accept )
82
72
 
83
- @req.accepts?( 'text/html' ).should be_true()
84
- @req.accepts?( 'text/plain' ).should be_true()
85
- @req.accepts?( 'text/ascii' ).should be_true()
86
- @req.accepts?( 'image/png' ).should be_true()
87
- @req.accepts?( 'application/x-yaml' ).should be_true()
73
+ expect( @req.accepts?( 'text/html' ) ).to be_true()
74
+ expect( @req.accepts?( 'text/plain' ) ).to be_true()
75
+ expect( @req.accepts?( 'text/ascii' ) ).to be_true()
76
+ expect( @req.accepts?( 'image/png' ) ).to be_true()
77
+ expect( @req.accepts?( 'application/x-yaml' ) ).to be_true()
88
78
  end
89
79
 
90
80
  it "doesn't explicitly accept anything if the client doesn't provide an Accept header" do
91
81
  @req.headers.delete( :accept )
92
82
 
93
- @req.explicitly_accepts?( 'text/html' ).should be_false()
94
- @req.explicitly_accepts?( 'text/plain' ).should be_false()
95
- @req.explicitly_accepts?( 'text/ascii' ).should be_false()
96
- @req.explicitly_accepts?( 'image/png' ).should be_false()
97
- @req.explicitly_accepts?( 'application/x-yaml' ).should be_false()
83
+ expect( @req.explicitly_accepts?( 'text/html' ) ).to be_false()
84
+ expect( @req.explicitly_accepts?( 'text/plain' ) ).to be_false()
85
+ expect( @req.explicitly_accepts?( 'text/ascii' ) ).to be_false()
86
+ expect( @req.explicitly_accepts?( 'image/png' ) ).to be_false()
87
+ expect( @req.explicitly_accepts?( 'application/x-yaml' ) ).to be_false()
98
88
  end
99
89
 
100
90
  end
@@ -105,33 +95,33 @@ describe Strelka::HTTPRequest::Negotiation do
105
95
  it "knows what character sets are accepted by the client" do
106
96
  @req.headers.accept_charset = 'iso-8859-5, utf-8;q=0.8'
107
97
 
108
- @req.accepted_charsets.should have(2).members
109
- @req.accepted_charsets[0].name.should == 'iso-8859-5'
110
- @req.accepted_charsets[0].qvalue.should == 1.0
111
- @req.accepted_charsets[1].name.should == 'utf-8'
112
- @req.accepted_charsets[1].qvalue.should == 0.8
98
+ expect( @req.accepted_charsets ).to have(2).members
99
+ expect( @req.accepted_charsets[0].name ).to eq( 'iso-8859-5' )
100
+ expect( @req.accepted_charsets[0].qvalue ).to eq( 1.0 )
101
+ expect( @req.accepted_charsets[1].name ).to eq( 'utf-8' )
102
+ expect( @req.accepted_charsets[1].qvalue ).to eq( 0.8 )
113
103
  end
114
104
 
115
105
  it "knows what charsets are acceptable responses" do
116
106
  @req.headers.accept_charset = 'iso-8859-5, utf-8;q=0.8'
117
107
 
118
- @req.accepts_charset?( 'iso8859-5' ).should be_true()
119
- @req.accepts_charset?( 'iso-8859-5' ).should be_true()
120
- @req.accepts_charset?( 'utf-8' ).should be_true()
121
- @req.accepts_charset?( Encoding::CP65001 ).should be_true()
122
- @req.accepts_charset?( 'mac' ).should be_false()
123
- @req.accepts_charset?( Encoding::SJIS ).should be_false()
108
+ expect( @req.accepts_charset?( 'iso8859-5' ) ).to be_true()
109
+ expect( @req.accepts_charset?( 'iso-8859-5' ) ).to be_true()
110
+ expect( @req.accepts_charset?( 'utf-8' ) ).to be_true()
111
+ expect( @req.accepts_charset?( Encoding::CP65001 ) ).to be_true()
112
+ expect( @req.accepts_charset?( 'mac' ) ).to be_false()
113
+ expect( @req.accepts_charset?( Encoding::SJIS ) ).to be_false()
124
114
  end
125
115
 
126
116
  it "accepts any charset if the client doesn't provide an Accept-Charset header" do
127
117
  @req.headers.delete( :accept_charset )
128
118
 
129
- @req.accepts_charset?( 'iso8859-5' ).should be_true()
130
- @req.accepts_charset?( 'iso-8859-5' ).should be_true()
131
- @req.accepts_charset?( 'utf-8' ).should be_true()
132
- @req.accepts_charset?( Encoding::CP65001 ).should be_true()
133
- @req.accepts_charset?( 'mac' ).should be_true()
134
- @req.accepts_charset?( Encoding::SJIS ).should be_true()
119
+ expect( @req.accepts_charset?( 'iso8859-5' ) ).to be_true()
120
+ expect( @req.accepts_charset?( 'iso-8859-5' ) ).to be_true()
121
+ expect( @req.accepts_charset?( 'utf-8' ) ).to be_true()
122
+ expect( @req.accepts_charset?( Encoding::CP65001 ) ).to be_true()
123
+ expect( @req.accepts_charset?( 'mac' ) ).to be_true()
124
+ expect( @req.accepts_charset?( Encoding::SJIS ) ).to be_true()
135
125
  end
136
126
 
137
127
  end
@@ -142,63 +132,63 @@ describe Strelka::HTTPRequest::Negotiation do
142
132
  it "knows what encodings are accepted by the client" do
143
133
  @req.headers.accept_encoding = 'gzip;q=1.0, identity; q=0.5, *;q=0'
144
134
 
145
- @req.accepted_encodings.should have(3).members
146
- @req.accepted_encodings[0].content_coding.should == 'gzip'
147
- @req.accepted_encodings[0].qvalue.should == 1.0
148
- @req.accepted_encodings[1].content_coding.should == 'identity'
149
- @req.accepted_encodings[1].qvalue.should == 0.5
150
- @req.accepted_encodings[2].content_coding.should be_nil()
151
- @req.accepted_encodings[2].qvalue.should == 0.0
135
+ expect( @req.accepted_encodings ).to have(3).members
136
+ expect( @req.accepted_encodings[0].content_coding ).to eq( 'gzip' )
137
+ expect( @req.accepted_encodings[0].qvalue ).to eq( 1.0 )
138
+ expect( @req.accepted_encodings[1].content_coding ).to eq( 'identity' )
139
+ expect( @req.accepted_encodings[1].qvalue ).to eq( 0.5 )
140
+ expect( @req.accepted_encodings[2].content_coding ).to be_nil()
141
+ expect( @req.accepted_encodings[2].qvalue ).to eq( 0.0 )
152
142
  end
153
143
 
154
144
  it "knows what encodings are acceptable" do
155
145
  @req.headers.accept_encoding = 'gzip;q=1.0, identity; q=0.5, *;q=0'
156
146
 
157
- @req.accepts_encoding?( 'gzip' ).should be_true()
158
- @req.accepts_encoding?( 'identity' ).should be_true()
159
- @req.accepts_encoding?( 'compress' ).should be_false()
147
+ expect( @req.accepts_encoding?( 'gzip' ) ).to be_true()
148
+ expect( @req.accepts_encoding?( 'identity' ) ).to be_true()
149
+ expect( @req.accepts_encoding?( 'compress' ) ).to be_false()
160
150
  end
161
151
 
162
152
  it "knows that the identity encoding is acceptable if it isn't disabled" do
163
153
  @req.headers.accept_encoding = 'gzip;q=1.0, compress; q=0.5'
164
154
 
165
- @req.accepts_encoding?( 'gzip' ).should be_true()
166
- @req.accepts_encoding?( 'identity' ).should be_true()
167
- @req.accepts_encoding?( 'compress' ).should be_true()
168
- @req.accepts_encoding?( 'clowns' ).should be_false()
155
+ expect( @req.accepts_encoding?( 'gzip' ) ).to be_true()
156
+ expect( @req.accepts_encoding?( 'identity' ) ).to be_true()
157
+ expect( @req.accepts_encoding?( 'compress' ) ).to be_true()
158
+ expect( @req.accepts_encoding?( 'clowns' ) ).to be_false()
169
159
  end
170
160
 
171
161
  it "accepts only the 'identity' encoding if the Accept-Encoding field is empty" do
172
162
  @req.headers.accept_encoding = ''
173
163
 
174
- @req.accepts_encoding?( 'identity' ).should be_true()
175
- @req.accepts_encoding?( 'gzip' ).should be_false()
176
- @req.accepts_encoding?( 'compress' ).should be_false()
164
+ expect( @req.accepts_encoding?( 'identity' ) ).to be_true()
165
+ expect( @req.accepts_encoding?( 'gzip' ) ).to be_false()
166
+ expect( @req.accepts_encoding?( 'compress' ) ).to be_false()
177
167
  end
178
168
 
179
169
  it "doesn't accept the 'identity' encoding if the Accept-Encoding field explicitly disables it" do
180
170
  @req.headers.accept_encoding = 'gzip;q=0.5, identity;q=0'
181
171
 
182
- @req.accepts_encoding?( 'identity' ).should be_false()
183
- @req.accepts_encoding?( 'gzip' ).should be_true()
184
- @req.accepts_encoding?( 'compress' ).should be_false()
172
+ expect( @req.accepts_encoding?( 'identity' ) ).to be_false()
173
+ expect( @req.accepts_encoding?( 'gzip' ) ).to be_true()
174
+ expect( @req.accepts_encoding?( 'compress' ) ).to be_false()
185
175
  end
186
176
 
187
177
  it "doesn't accept the 'identity' encoding if the Accept-Encoding field has a wildcard " +
188
178
  "with q-value of 0 and doesn't explicitly include 'identity'" do
189
179
  @req.headers.accept_encoding = 'gzip;q=0.5, *;q=0'
190
180
 
191
- @req.accepts_encoding?( 'identity' ).should be_false()
192
- @req.accepts_encoding?( 'gzip' ).should be_true()
193
- @req.accepts_encoding?( 'compress' ).should be_false()
181
+ expect( @req.accepts_encoding?( 'identity' ) ).to be_false()
182
+ expect( @req.accepts_encoding?( 'gzip' ) ).to be_true()
183
+ expect( @req.accepts_encoding?( 'compress' ) ).to be_false()
194
184
  end
195
185
 
196
186
  it "accepts every encoding if the request doesn't have an Accept-Encoding header" do
197
187
  @req.headers.delete( :accept_encoding )
198
188
 
199
- @req.accepts_encoding?( 'identity' ).should be_true()
200
- @req.accepts_encoding?( 'gzip' ).should be_true()
201
- @req.accepts_encoding?( 'compress' ).should be_true()
189
+ expect( @req.accepts_encoding?( 'identity' ) ).to be_true()
190
+ expect( @req.accepts_encoding?( 'gzip' ) ).to be_true()
191
+ expect( @req.accepts_encoding?( 'compress' ) ).to be_true()
202
192
  end
203
193
 
204
194
  end
@@ -209,38 +199,38 @@ describe Strelka::HTTPRequest::Negotiation do
209
199
  it "knows what languages are accepted by the client" do
210
200
  @req.headers.accept_language = 'da, en-gb;q=0.8, en;q=0.7'
211
201
 
212
- @req.accepted_languages.should have(3).members
213
- @req.accepted_languages[0].primary_tag.should == 'da'
214
- @req.accepted_languages[0].subtag.should == nil
215
- @req.accepted_languages[0].qvalue.should == 1.0
216
- @req.accepted_languages[1].primary_tag.should == 'en'
217
- @req.accepted_languages[1].subtag.should == 'gb'
218
- @req.accepted_languages[1].qvalue.should == 0.8
219
- @req.accepted_languages[2].primary_tag.should == 'en'
220
- @req.accepted_languages[2].subtag.should == nil
221
- @req.accepted_languages[2].qvalue.should == 0.7
202
+ expect( @req.accepted_languages ).to have(3).members
203
+ expect( @req.accepted_languages[0].primary_tag ).to eq( 'da' )
204
+ expect( @req.accepted_languages[0].subtag ).to eq( nil )
205
+ expect( @req.accepted_languages[0].qvalue ).to eq( 1.0 )
206
+ expect( @req.accepted_languages[1].primary_tag ).to eq( 'en' )
207
+ expect( @req.accepted_languages[1].subtag ).to eq( 'gb' )
208
+ expect( @req.accepted_languages[1].qvalue ).to eq( 0.8 )
209
+ expect( @req.accepted_languages[2].primary_tag ).to eq( 'en' )
210
+ expect( @req.accepted_languages[2].subtag ).to eq( nil )
211
+ expect( @req.accepted_languages[2].qvalue ).to eq( 0.7 )
222
212
  end
223
213
 
224
214
  it "knows what languages may be used in acceptable responses" do
225
215
  @req.headers.accept_language = 'da, en-gb;q=0.8, en;q=0.7'
226
216
 
227
- @req.accepts_language?( 'da' ).should be_true()
228
- @req.accepts_language?( 'en' ).should be_true()
229
- @req.accepts_language?( 'en-gb' ).should be_true()
230
- @req.accepts_language?( 'en-cockney' ).should be_true()
231
- @req.accepts_language?( 'de' ).should be_false()
232
- @req.accepts_language?( 'tlh' ).should be_false()
217
+ expect( @req.accepts_language?( 'da' ) ).to be_true()
218
+ expect( @req.accepts_language?( 'en' ) ).to be_true()
219
+ expect( @req.accepts_language?( 'en-gb' ) ).to be_true()
220
+ expect( @req.accepts_language?( 'en-cockney' ) ).to be_true()
221
+ expect( @req.accepts_language?( 'de' ) ).to be_false()
222
+ expect( @req.accepts_language?( 'tlh' ) ).to be_false()
233
223
  end
234
224
 
235
225
  it "accepts any language if the client doesn't provide an Accept-Language header" do
236
226
  @req.headers.delete( :accept_language )
237
227
 
238
- @req.accepts_language?( 'da' ).should be_true()
239
- @req.accepts_language?( 'en' ).should be_true()
240
- @req.accepts_language?( 'en-gb' ).should be_true()
241
- @req.accepts_language?( 'en-cockney' ).should be_true()
242
- @req.accepts_language?( 'de' ).should be_true()
243
- @req.accepts_language?( 'tlh' ).should be_true()
228
+ expect( @req.accepts_language?( 'da' ) ).to be_true()
229
+ expect( @req.accepts_language?( 'en' ) ).to be_true()
230
+ expect( @req.accepts_language?( 'en-gb' ) ).to be_true()
231
+ expect( @req.accepts_language?( 'en-cockney' ) ).to be_true()
232
+ expect( @req.accepts_language?( 'de' ) ).to be_true()
233
+ expect( @req.accepts_language?( 'tlh' ) ).to be_true()
244
234
  end
245
235
 
246
236
  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'
@@ -48,28 +38,28 @@ describe Strelka::HTTPRequest::Session, "-extended request" do
48
38
 
49
39
 
50
40
  it "has a session_namespace attribute" do
51
- @req.should respond_to( :session_namespace )
41
+ expect( @req ).to respond_to( :session_namespace )
52
42
  end
53
43
 
54
44
 
55
45
  context "with no session ID" do
56
46
 
57
47
  it "knows that it doesn't have a session" do
58
- @req.should_not have_session()
48
+ expect( @req ).to_not have_session()
59
49
  end
60
50
 
61
51
  it "doesn't load the session when the session namespace is set" do
62
52
  @req.session_namespace = 'an_appid'
63
- @req.should_not have_session()
53
+ expect( @req ).to_not have_session()
64
54
  end
65
55
 
66
56
  it "creates a new session as soon as it's accessed" do
67
- @req.session.should be_a( Strelka::Session::Default )
57
+ expect( @req.session ).to be_a( Strelka::Session::Default )
68
58
  end
69
59
 
70
60
  it "sets its session's namespace when it loads if the session_namespace is set" do
71
61
  @req.session_namespace = 'an_appid'
72
- @req.session.namespace.should == :an_appid
62
+ expect( @req.session.namespace ).to eq( :an_appid )
73
63
  end
74
64
 
75
65
 
@@ -81,12 +71,12 @@ describe Strelka::HTTPRequest::Session, "-extended request" do
81
71
  end
82
72
 
83
73
  it "knows that it has a session" do
84
- @req.should have_session()
74
+ expect( @req ).to have_session()
85
75
  end
86
76
 
87
77
  it "sets the session's namespace when its session_namespace is set" do
88
78
  @req.session_namespace = 'the_appid'
89
- @session.namespace.should == :the_appid
79
+ expect( @session.namespace ).to eq( :the_appid )
90
80
  end
91
81
  end
92
82
 
@@ -100,7 +90,7 @@ describe Strelka::HTTPRequest::Session, "-extended request" do
100
90
  end
101
91
 
102
92
  it "knows that it doesn't have a session unless the ID exists" do
103
- @req.should_not have_session()
93
+ expect( @req ).to_not have_session()
104
94
  end
105
95
 
106
96
 
@@ -113,16 +103,16 @@ describe Strelka::HTTPRequest::Session, "-extended request" do
113
103
  it "knows that it has a session" do
114
104
  cookie_name = Strelka::Session::Default.cookie_name
115
105
  @req.header.cookie = "#{cookie_name}=#{@sess_id}"
116
- @req.should have_session()
106
+ expect( @req ).to have_session()
117
107
  end
118
108
 
119
109
  it "knows when its session hasn't been loaded" do
120
- @req.session_loaded?.should be_false()
110
+ expect( @req.session_loaded? ).to be_false()
121
111
  end
122
112
 
123
113
  it "knows when its session has been loaded" do
124
114
  @req.session # Load it
125
- @req.session_loaded?.should be_true()
115
+ expect( @req.session_loaded? ).to be_true()
126
116
  end
127
117
 
128
118
  end
@@ -2,16 +2,10 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
8
-
9
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
- }
5
+ require_relative '../helpers'
11
6
 
12
7
  require 'uri'
13
8
  require 'rspec'
14
- require 'spec/lib/helpers'
15
9
  require 'strelka/httprequest'
16
10
  require 'strelka/cookie'
17
11