From 90f6a5a998f95ca0196a69ac33587087e24229f5 Mon Sep 17 00:00:00 2001 From: Shih-Ying Allen Chen Date: Tue, 4 Jun 2019 22:45:26 +0800 Subject: [PATCH] Fix srem to allow passing an array of integers as argument --- lib/mock_redis/set_methods.rb | 1 + spec/commands/srem_spec.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/mock_redis/set_methods.rb b/lib/mock_redis/set_methods.rb index 566ee136..6ce25782 100644 --- a/lib/mock_redis/set_methods.rb +++ b/lib/mock_redis/set_methods.rb @@ -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 diff --git a/spec/commands/srem_spec.rb b/spec/commands/srem_spec.rb index 94685c1e..0ca196ce 100644 --- a/spec/commands/srem_spec.rb +++ b/spec/commands/srem_spec.rb @@ -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