Skip to content

Commit

Permalink
Fix srem to allow passing an array of integers as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
glasses618 authored and sds committed Jun 4, 2019
1 parent 40f73e6 commit 90f6a5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mock_redis/set_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def srem(key, members)
with_set_at(key) do |s|
if members.is_a?(Array)
orig_size = s.size
members = members.map(&:to_s)
s.delete_if { |m| members.include?(m) }
orig_size - s.size
else
Expand Down
5 changes: 5 additions & 0 deletions spec/commands/srem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@
@redises.get(@key).should be_nil
end

it 'allow passing an array of integers as argument' do
@redises.sadd(@key, %w[1 2])
@redises.srem(@key, [1, 2]).should == 2
end

it_should_behave_like 'a set-only command'
end

0 comments on commit 90f6a5a

Please sign in to comment.