diff --git a/lib/mock_redis/set_methods.rb b/lib/mock_redis/set_methods.rb index ad8c10b..8cac181 100644 --- a/lib/mock_redis/set_methods.rb +++ b/lib/mock_redis/set_methods.rb @@ -119,14 +119,13 @@ def srandmember(key, count = nil) end def srem(key, members) + members = Array(members).map(&:to_s) + 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 + if members.size > 1 || redis_gem_v5? + size_after(s) { s.delete_if { |m| members.include?(m) } } else - s.delete?(members.to_s) ? 1 : 0 + !!s.delete?(members.first) end end end