@@ -87,6 +87,50 @@ def test_psubscribe_and_punsubscribe
87
87
assert_equal "s1" , @message
88
88
end
89
89
90
+ def test_pubsub_with_numpat_subcommand
91
+ target_version ( "2.8.0" ) do
92
+ @subscribed = false
93
+ wire = Wire . new do
94
+ r . psubscribe ( "f*" ) do |on |
95
+ on . psubscribe { |channel , total | @subscribed = true }
96
+ on . pmessage { |pattern , channel , message | r . punsubscribe }
97
+ end
98
+ end
99
+ Wire . pass while !@subscribed
100
+ redis = Redis . new ( OPTIONS )
101
+ numpat_result = redis . pubsub ( :numpat )
102
+
103
+ redis . publish ( "foo" , "s1" )
104
+ wire . join
105
+
106
+ assert_equal redis . pubsub ( :numpat ) , 0
107
+ assert_equal numpat_result , 1
108
+ end
109
+ end
110
+
111
+
112
+ def test_pubsub_with_channels_and_numsub_subcommnads
113
+ target_version ( "2.8.0" ) do
114
+ @subscribed = false
115
+ wire = Wire . new do
116
+ r . subscribe ( "foo" ) do |on |
117
+ on . subscribe { |channel , total | @subscribed = true }
118
+ on . message { |channel , message | r . unsubscribe }
119
+ end
120
+ end
121
+ Wire . pass while !@subscribed
122
+ redis = Redis . new ( OPTIONS )
123
+ channels_result = redis . pubsub ( :channels )
124
+ numsub_result = redis . pubsub ( :numsub , 'foo' , 'boo' )
125
+
126
+ redis . publish ( "foo" , "s1" )
127
+ wire . join
128
+
129
+ assert_equal channels_result , [ 'foo' ]
130
+ assert_equal numsub_result , [ 'foo' , '1' , 'boo' , '0' ]
131
+ end
132
+ end
133
+
90
134
def test_subscribe_connection_usable_after_raise
91
135
@subscribed = false
92
136
0 commit comments