|
33 | 33 | end
|
34 | 34 |
|
35 | 35 | it "should raise an error if the servlet request is not present" do
|
36 |
| - lambda { @session_store.call({}) }.should raise_error |
| 36 | + expect { @session_store.call({}) }.to raise_error(RuntimeError) |
37 | 37 | end
|
38 | 38 |
|
39 | 39 | it "should do nothing if the session is not accessed" do
|
|
57 | 57 | it "should load the session when accessed" do
|
58 | 58 | @request.should_receive(:getSession).with(false).and_return @session
|
59 | 59 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
60 |
| - @app.should_receive(:call).and_return do |env| |
| 60 | + @app.should_receive(:call) do |env| |
61 | 61 | env['rack.session']['foo']
|
62 | 62 | end
|
63 | 63 | @session_store.call(@env)
|
|
73 | 73 | it "should report session loaded when accessed" do
|
74 | 74 | @request.should_receive(:getSession).with(false).and_return @session
|
75 | 75 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
76 |
| - @app.should_receive(:call).and_return do |env| |
| 76 | + @app.should_receive(:call) do |env| |
77 | 77 | env['rack.session']['foo']
|
78 | 78 | end
|
79 | 79 | @session_store.call(@env)
|
|
84 | 84 | it "should use custom session hash when loading session" do
|
85 | 85 | @request.should_receive(:getSession).with(false).and_return @session
|
86 | 86 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
87 |
| - @app.should_receive(:call).and_return do |env| |
| 87 | + @app.should_receive(:call) do |env| |
88 | 88 | env['rack.session']["foo"] = "bar"
|
89 | 89 | end
|
90 | 90 | @session_store.call(@env)
|
|
106 | 106 | @session.should_receive(:getAttributeNames).and_return [session_key]
|
107 | 107 | @session.should_receive(:getAttribute).with(session_key).and_return marshal_data.to_java_bytes
|
108 | 108 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
109 |
| - @app.should_receive(:call).and_return do |env| |
| 109 | + @app.should_receive(:call) do |env| |
110 | 110 | env['rack.session']["foo"].should == 1
|
111 | 111 | env['rack.session']["bar"].should == true
|
112 | 112 | end
|
|
120 | 120 | @session.should_receive(:getAttribute).with("foo").and_return hash["foo"]
|
121 | 121 | @session.should_receive(:getAttribute).with("bar").and_return hash["bar"]
|
122 | 122 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
123 |
| - @app.should_receive(:call).and_return do |env| |
| 123 | + @app.should_receive(:call) do |env| |
124 | 124 | env['rack.session']["foo"].should == hash["foo"]
|
125 | 125 | env['rack.session']["bar"].should == hash["bar"]
|
126 | 126 | end
|
|
132 | 132 | @session.should_receive(:getAttributeNames).and_return ["foo"]
|
133 | 133 | @session.should_receive(:getAttribute).with("foo").and_return java.lang.Object.new
|
134 | 134 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
135 |
| - @app.should_receive(:call).and_return do |env| |
| 135 | + @app.should_receive(:call) do |env| |
136 | 136 | env['rack.session']["foo"].should be_kind_of(java.lang.Object)
|
137 | 137 | end
|
138 | 138 | @session_store.call(@env)
|
|
143 | 143 | @session.stub(:getAttribute).and_return nil; @session.stub(:getCreationTime).and_return 1
|
144 | 144 | @session.should_receive(:setAttribute).with(ActionController::Session::JavaServletStore::RAILS_SESSION_KEY,
|
145 | 145 | an_instance_of(Java::byte[]))
|
146 |
| - @app.should_receive(:call).and_return do |env| |
| 146 | + @app.should_receive(:call) do |env| |
147 | 147 | env['rack.session']['foo'] = Object.new
|
148 | 148 | end
|
149 | 149 | @session_store.call(@env)
|
|
154 | 154 | @request.should_receive(:getSession).with(true).ordered.and_return @session
|
155 | 155 | @session.should_receive(:setAttribute).with(ActionController::Session::JavaServletStore::RAILS_SESSION_KEY,
|
156 | 156 | an_instance_of(Java::byte[]))
|
157 |
| - @app.should_receive(:call).and_return do |env| |
| 157 | + @app.should_receive(:call) do |env| |
158 | 158 | env['rack.session']['foo'] = Object.new
|
159 | 159 | end
|
160 | 160 | @session_store.call(@env)
|
|
164 | 164 | @request.should_receive(:getSession).with(false).and_return @session
|
165 | 165 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
166 | 166 | @session.should_receive(:setAttribute).with("foo", "bar")
|
167 |
| - @app.should_receive(:call).and_return do |env| |
| 167 | + @app.should_receive(:call) do |env| |
168 | 168 | env['rack.session']["foo"] = "bar"
|
169 | 169 | end
|
170 | 170 | @session_store.call(@env)
|
|
176 | 176 | @session.should_receive(:setAttribute).with("foo", true)
|
177 | 177 | @session.should_receive(:setAttribute).with("bar", 20)
|
178 | 178 | @session.should_receive(:setAttribute).with("baz", false)
|
179 |
| - @app.should_receive(:call).and_return do |env| |
| 179 | + @app.should_receive(:call) do |env| |
180 | 180 | env['rack.session']["foo"] = true
|
181 | 181 | env['rack.session']["bar"] = 20
|
182 | 182 | env['rack.session']["baz"] = false
|
|
188 | 188 | @request.should_receive(:getSession).with(false).and_return @session
|
189 | 189 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
190 | 190 | @session.should_receive(:setAttribute).with("foo", an_instance_of(java.lang.Object))
|
191 |
| - @app.should_receive(:call).and_return do |env| |
| 191 | + @app.should_receive(:call) do |env| |
192 | 192 | env['rack.session']["foo"] = java.lang.Object.new
|
193 | 193 | end
|
194 | 194 | @session_store.call(@env)
|
|
200 | 200 | @session.stub(:setAttribute); @session.stub(:getCreationTime).and_return 1
|
201 | 201 | @session.should_receive(:removeAttribute).with("foo")
|
202 | 202 | @session.should_receive(:removeAttribute).with("baz")
|
203 |
| - @app.should_receive(:call).and_return do |env| |
| 203 | + @app.should_receive(:call) do |env| |
204 | 204 | env['rack.session'].delete('foo')
|
205 | 205 | env['rack.session']['baz'] = nil
|
206 | 206 | env['rack.session']['bar'] = 'x'
|
|
212 | 212 | @request.should_receive(:getSession).with(false).and_return @session
|
213 | 213 | @session.stub(:getId).and_return(nil)
|
214 | 214 | @session.should_receive(:invalidate).ordered
|
215 |
| - @app.should_receive(:call).and_return do |env| |
| 215 | + @app.should_receive(:call) do |env| |
216 | 216 | env['rack.session.options'].delete(:id)
|
217 | 217 | #env['rack.session'] = new_session_hash(env)
|
218 | 218 | env['rack.session'].send :load!
|
|
224 | 224 | session = double_http_session(nil); session.invalidate
|
225 | 225 | @request.should_receive(:getSession).with(false).and_return session
|
226 | 226 |
|
227 |
| - @app.should_receive(:call).and_return do |env| |
| 227 | + @app.should_receive(:call) do |env| |
228 | 228 | env['rack.session.options'].delete(:id)
|
229 | 229 | env['rack.session'].send :load!
|
230 | 230 | end
|
231 |
| - expect( lambda { @session_store.call(@env) } ).to_not raise_error |
| 231 | + expect { @session_store.call(@env) }.to_not raise_error |
232 | 232 | end
|
233 | 233 |
|
234 | 234 | it "should handle session with an invalid servlet session" do
|
|
240 | 240 | @request.should_receive(:getSession).ordered.
|
241 | 241 | with(true).and_return new_session = double_http_session
|
242 | 242 |
|
243 |
| - @app.should_receive(:call).and_return do |env| |
| 243 | + @app.should_receive(:call) do |env| |
244 | 244 | env['rack.session']['foo'] = 'bar'
|
245 | 245 | end
|
246 | 246 | @session_store.call(@env)
|
247 | 247 | end
|
248 | 248 |
|
249 | 249 | it "should do nothing on session reset if no session is established" do
|
250 | 250 | @request.should_receive(:getSession).with(false).and_return nil
|
251 |
| - @app.should_receive(:call).and_return do |env| |
| 251 | + @app.should_receive(:call) do |env| |
252 | 252 | env['rack.session.options'].delete(:id)
|
253 | 253 | env['rack.session'] = new_session_hash(env) # not loaded?
|
254 | 254 | end
|
|
260 | 260 | @request.should_receive(:getSession).and_return @session
|
261 | 261 | @session.should_receive(:getLastAccessedTime).and_return time
|
262 | 262 | @session.stub(:setAttribute)
|
263 |
| - @app.should_receive(:call).and_return do |env| |
| 263 | + @app.should_receive(:call) do |env| |
264 | 264 | env['rack.session'].getLastAccessedTime.should == time
|
265 | 265 | lambda { env['rack.session'].blah_blah }.should raise_error(NoMethodError)
|
266 | 266 | end
|
|
274 | 274 | new_session = double_http_session
|
275 | 275 | @request.should_receive(:getSession).ordered.with(true).and_return(new_session)
|
276 | 276 |
|
277 |
| - @app.should_receive(:call).and_return do |env| |
| 277 | + @app.should_receive(:call) do |env| |
278 | 278 | env['rack.session.options'] = { :id => sid, :renew => true, :defer => true }
|
279 | 279 | env['rack.session']['_csrf_token'] = 'v3PrzsdkWug9Q3xCthKkEzUMbZSzgQ9Bt+43lH0bEF8='
|
280 | 280 | end
|
|
292 | 292 | it "handles the skip session option" do
|
293 | 293 | @request.should_receive(:getSession).with(false).and_return @session
|
294 | 294 | @session.should_not_receive(:setAttribute)
|
295 |
| - @app.should_receive(:call).and_return do |env| |
| 295 | + @app.should_receive(:call) do |env| |
296 | 296 | env['rack.session.options'][:skip] = true
|
297 | 297 | env['rack.session']['foo'] = 'bar'
|
298 | 298 | end
|
299 |
| - expect( lambda { @session_store.call(@env) } ).to_not raise_error |
| 299 | + expect { @session_store.call(@env) }.to_not raise_error |
300 | 300 | end
|
301 | 301 |
|
302 | 302 | private
|
|
0 commit comments