@@ -253,40 +253,30 @@ def test_subscribe_past_a_timeout
253
253
end
254
254
255
255
def test_subscribe_with_timeout
256
- assert_raise Redis ::TimeoutError do
257
- sleep = %{sleep #{ OPTIONS [ :timeout ] * 2 } }
258
- publish = %{echo "publish foo bar\r \n " | nc localhost #{ OPTIONS [ :port ] } }
259
- cmd = [ sleep , publish ] . join ( "; " )
260
-
261
- IO . popen ( cmd , "r+" ) do |pipe |
262
- received = false
256
+ received = false
263
257
264
- r . subscribe_with_timeout ( OPTIONS [ :timeout ] , "foo" ) do |on |
265
- on . message do |channel , message |
266
- received = true
267
- r . unsubscribe
268
- end
258
+ assert_raise Redis ::TimeoutError do
259
+ r . subscribe_with_timeout ( 1 , "foo" ) do |on |
260
+ on . message do |channel , message |
261
+ received = true
269
262
end
270
263
end
271
264
end
265
+
266
+ assert !received
272
267
end
273
268
274
269
def test_psubscribe_with_timeout
275
- assert_raise Redis ::TimeoutError do
276
- sleep = %{sleep #{ OPTIONS [ :timeout ] * 2 } }
277
- publish = %{echo "publish foo bar\r \n " | nc localhost #{ OPTIONS [ :port ] } }
278
- cmd = [ sleep , publish ] . join ( "; " )
279
-
280
- IO . popen ( cmd , "r+" ) do |pipe |
281
- received = false
270
+ received = false
282
271
283
- r . psubscribe_with_timeout ( OPTIONS [ :timeout ] , "f*" ) do |on |
284
- on . message do |channel , message |
285
- received = true
286
- r . unsubscribe
287
- end
272
+ assert_raise Redis ::TimeoutError do
273
+ r . psubscribe_with_timeout ( 1 , "f*" ) do |on |
274
+ on . message do |channel , message |
275
+ received = true
288
276
end
289
277
end
290
278
end
279
+
280
+ assert !received
291
281
end
292
282
end
0 commit comments