File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,11 @@ def srem(key, members)
137
137
end
138
138
end
139
139
140
+ def srem? ( key , members )
141
+ res = srem ( key , members )
142
+ res . is_a? ( Numeric ) ? res > 0 : res
143
+ end
144
+
140
145
def sscan ( key , cursor , opts = { } )
141
146
common_scan ( smembers ( key ) , cursor , opts )
142
147
end
Original file line number Diff line number Diff line change 41
41
expect ( @redises . srem ( @key , [ 1 , 2 ] ) ) . to eq ( 2 )
42
42
end
43
43
44
+ context 'srem?' do
45
+ it 'returns true if member is in the set' do
46
+ expect ( @redises . srem? ( @key , 'bert' ) ) . to eq ( true )
47
+ end
48
+
49
+ it 'returns false if member is not in the set' do
50
+ expect ( @redises . srem? ( @key , 'cookiemonster' ) ) . to eq ( false )
51
+ end
52
+
53
+ it 'removes member from the set' do
54
+ @redises . srem? ( @key , 'ernie' )
55
+ expect ( @redises . smembers ( @key ) ) . to eq ( [ 'bert' ] )
56
+ end
57
+ end
58
+
44
59
it_should_behave_like 'a set-only command'
45
60
end
You can’t perform that action at this time.
0 commit comments