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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ChangeLog +156 -9
- data/History.rdoc +15 -0
- data/IDEAS.rdoc +17 -1
- data/MILESTONES.rdoc +1 -1
- data/Manifest.txt +10 -2
- data/Plugins.rdoc +4 -4
- data/README.rdoc +3 -3
- data/Rakefile +5 -4
- data/bin/strelka +19 -10
- data/contrib/hoetemplate/data/project/apps/file_name_app +1 -0
- data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
- data/examples/apps/hello-world +1 -0
- data/examples/apps/ws-chat +69 -0
- data/examples/apps/ws-echo +61 -0
- data/examples/gen-config.rb +6 -5
- data/lib/strelka/app/auth.rb +2 -2
- data/lib/strelka/app/errors.rb +1 -1
- data/lib/strelka/app/filters.rb +3 -2
- data/lib/strelka/app/negotiation.rb +2 -2
- data/lib/strelka/app/parameters.rb +1 -2
- data/lib/strelka/app/restresources.rb +3 -2
- data/lib/strelka/app/routing.rb +1 -1
- data/lib/strelka/app/sessions.rb +2 -2
- data/lib/strelka/app/templating.rb +7 -3
- data/lib/strelka/app.rb +5 -145
- data/lib/strelka/behavior/plugin.rb +4 -4
- data/lib/strelka/discovery.rb +211 -0
- data/lib/strelka/httprequest.rb +1 -0
- data/lib/strelka/httpresponse/negotiation.rb +7 -1
- data/lib/strelka/mixins.rb +4 -1
- data/lib/strelka/paramvalidator.rb +1 -1
- data/lib/strelka/plugins.rb +8 -6
- data/lib/strelka/websocketserver/routing.rb +116 -0
- data/lib/strelka/websocketserver.rb +147 -0
- data/lib/strelka.rb +5 -4
- data/spec/{lib/constants.rb → constants.rb} +3 -2
- data/spec/{lib/helpers.rb → helpers.rb} +15 -14
- data/spec/strelka/app/auth_spec.rb +145 -142
- data/spec/strelka/app/errors_spec.rb +20 -26
- data/spec/strelka/app/filters_spec.rb +67 -54
- data/spec/strelka/app/negotiation_spec.rb +8 -14
- data/spec/strelka/app/parameters_spec.rb +23 -29
- data/spec/strelka/app/restresources_spec.rb +98 -100
- data/spec/strelka/app/routing_spec.rb +57 -57
- data/spec/strelka/app/sessions_spec.rb +11 -17
- data/spec/strelka/app/templating_spec.rb +36 -40
- data/spec/strelka/app_spec.rb +48 -147
- data/spec/strelka/authprovider/basic_spec.rb +5 -11
- data/spec/strelka/authprovider/hostaccess_spec.rb +9 -15
- data/spec/strelka/authprovider_spec.rb +3 -9
- data/spec/strelka/cookie_spec.rb +32 -38
- data/spec/strelka/cookieset_spec.rb +31 -37
- data/spec/strelka/discovery_spec.rb +144 -0
- data/spec/strelka/exceptions_spec.rb +2 -8
- data/spec/strelka/httprequest/acceptparams_spec.rb +74 -83
- data/spec/strelka/httprequest/auth_spec.rb +5 -15
- data/spec/strelka/httprequest/negotiation_spec.rb +93 -103
- data/spec/strelka/httprequest/session_spec.rb +12 -22
- data/spec/strelka/httprequest_spec.rb +1 -7
- data/spec/strelka/httpresponse/negotiation_spec.rb +84 -76
- data/spec/strelka/httpresponse/session_spec.rb +25 -35
- data/spec/strelka/httpresponse_spec.rb +20 -26
- data/spec/strelka/mixins_spec.rb +66 -61
- data/spec/strelka/multipartparser_spec.rb +31 -37
- data/spec/strelka/paramvalidator_spec.rb +389 -373
- data/spec/strelka/plugins_spec.rb +17 -23
- data/spec/strelka/router/default_spec.rb +32 -38
- data/spec/strelka/router/exclusive_spec.rb +28 -34
- data/spec/strelka/router_spec.rb +2 -8
- data/spec/strelka/session/db_spec.rb +17 -15
- data/spec/strelka/session/default_spec.rb +22 -28
- data/spec/strelka/session_spec.rb +3 -9
- data/spec/strelka/websocketserver/routing_spec.rb +119 -0
- data/spec/strelka/websocketserver_spec.rb +149 -0
- data/spec/strelka_spec.rb +11 -13
- data.tar.gz.sig +3 -3
- metadata +22 -14
- 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
|
-
|
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.
|
52
|
-
@req.accepted_types[0].mediatype.
|
53
|
-
@req.accepted_types[0].qvalue.
|
54
|
-
@req.accepted_types[1].mediatype.
|
55
|
-
@req.accepted_types[1].qvalue.
|
56
|
-
@req.accepted_types[2].mediatype.
|
57
|
-
@req.accepted_types[2].qvalue.
|
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' ).
|
64
|
-
@req.accepts?( 'text/plain' ).
|
65
|
-
@req.accepts?( 'text/ascii' ).
|
66
|
-
@req.accepts?( 'image/png' ).
|
67
|
-
@req.accepts?( 'application/x-yaml' ).
|
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' ).
|
74
|
-
@req.explicitly_accepts?( 'text/plain' ).
|
75
|
-
@req.explicitly_accepts?( 'text/ascii' ).
|
76
|
-
@req.explicitly_accepts?( 'image/png' ).
|
77
|
-
@req.explicitly_accepts?( 'application/x-yaml' ).
|
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' ).
|
84
|
-
@req.accepts?( 'text/plain' ).
|
85
|
-
@req.accepts?( 'text/ascii' ).
|
86
|
-
@req.accepts?( 'image/png' ).
|
87
|
-
@req.accepts?( 'application/x-yaml' ).
|
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' ).
|
94
|
-
@req.explicitly_accepts?( 'text/plain' ).
|
95
|
-
@req.explicitly_accepts?( 'text/ascii' ).
|
96
|
-
@req.explicitly_accepts?( 'image/png' ).
|
97
|
-
@req.explicitly_accepts?( 'application/x-yaml' ).
|
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.
|
109
|
-
@req.accepted_charsets[0].name.
|
110
|
-
@req.accepted_charsets[0].qvalue.
|
111
|
-
@req.accepted_charsets[1].name.
|
112
|
-
@req.accepted_charsets[1].qvalue.
|
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' ).
|
119
|
-
@req.accepts_charset?( 'iso-8859-5' ).
|
120
|
-
@req.accepts_charset?( 'utf-8' ).
|
121
|
-
@req.accepts_charset?( Encoding::CP65001 ).
|
122
|
-
@req.accepts_charset?( 'mac' ).
|
123
|
-
@req.accepts_charset?( Encoding::SJIS ).
|
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' ).
|
130
|
-
@req.accepts_charset?( 'iso-8859-5' ).
|
131
|
-
@req.accepts_charset?( 'utf-8' ).
|
132
|
-
@req.accepts_charset?( Encoding::CP65001 ).
|
133
|
-
@req.accepts_charset?( 'mac' ).
|
134
|
-
@req.accepts_charset?( Encoding::SJIS ).
|
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.
|
146
|
-
@req.accepted_encodings[0].content_coding.
|
147
|
-
@req.accepted_encodings[0].qvalue.
|
148
|
-
@req.accepted_encodings[1].content_coding.
|
149
|
-
@req.accepted_encodings[1].qvalue.
|
150
|
-
@req.accepted_encodings[2].content_coding.
|
151
|
-
@req.accepted_encodings[2].qvalue.
|
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' ).
|
158
|
-
@req.accepts_encoding?( 'identity' ).
|
159
|
-
@req.accepts_encoding?( 'compress' ).
|
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' ).
|
166
|
-
@req.accepts_encoding?( 'identity' ).
|
167
|
-
@req.accepts_encoding?( 'compress' ).
|
168
|
-
@req.accepts_encoding?( 'clowns' ).
|
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' ).
|
175
|
-
@req.accepts_encoding?( 'gzip' ).
|
176
|
-
@req.accepts_encoding?( 'compress' ).
|
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' ).
|
183
|
-
@req.accepts_encoding?( 'gzip' ).
|
184
|
-
@req.accepts_encoding?( 'compress' ).
|
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' ).
|
192
|
-
@req.accepts_encoding?( 'gzip' ).
|
193
|
-
@req.accepts_encoding?( 'compress' ).
|
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' ).
|
200
|
-
@req.accepts_encoding?( 'gzip' ).
|
201
|
-
@req.accepts_encoding?( 'compress' ).
|
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.
|
213
|
-
@req.accepted_languages[0].primary_tag.
|
214
|
-
@req.accepted_languages[0].subtag.
|
215
|
-
@req.accepted_languages[0].qvalue.
|
216
|
-
@req.accepted_languages[1].primary_tag.
|
217
|
-
@req.accepted_languages[1].subtag.
|
218
|
-
@req.accepted_languages[1].qvalue.
|
219
|
-
@req.accepted_languages[2].primary_tag.
|
220
|
-
@req.accepted_languages[2].subtag.
|
221
|
-
@req.accepted_languages[2].qvalue.
|
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' ).
|
228
|
-
@req.accepts_language?( 'en' ).
|
229
|
-
@req.accepts_language?( 'en-gb' ).
|
230
|
-
@req.accepts_language?( 'en-cockney' ).
|
231
|
-
@req.accepts_language?( 'de' ).
|
232
|
-
@req.accepts_language?( 'tlh' ).
|
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' ).
|
239
|
-
@req.accepts_language?( 'en' ).
|
240
|
-
@req.accepts_language?( 'en-gb' ).
|
241
|
-
@req.accepts_language?( 'en-cockney' ).
|
242
|
-
@req.accepts_language?( 'de' ).
|
243
|
-
@req.accepts_language?( 'tlh' ).
|
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
|
-
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
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
|
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
|
-
|
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
|
|