mock_redis 0.35.0 → 0.37.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +3 -3
  4. data/lib/mock_redis/database.rb +1 -1
  5. data/lib/mock_redis/hash_methods.rb +1 -1
  6. data/lib/mock_redis/list_methods.rb +37 -2
  7. data/lib/mock_redis/multi_db_wrapper.rb +1 -1
  8. data/lib/mock_redis/pipelined_wrapper.rb +12 -14
  9. data/lib/mock_redis/set_methods.rb +12 -1
  10. data/lib/mock_redis/stream.rb +3 -3
  11. data/lib/mock_redis/string_methods.rb +3 -3
  12. data/lib/mock_redis/transaction_wrapper.rb +5 -7
  13. data/lib/mock_redis/utility_methods.rb +4 -2
  14. data/lib/mock_redis/version.rb +1 -1
  15. data/lib/mock_redis/zset.rb +4 -2
  16. data/lib/mock_redis/zset_methods.rb +4 -4
  17. data/lib/mock_redis.rb +1 -2
  18. metadata +19 -354
  19. data/.github/workflows/lint.yml +0 -31
  20. data/.github/workflows/tests.yml +0 -63
  21. data/.gitignore +0 -5
  22. data/.mailmap +0 -2
  23. data/.overcommit.yml +0 -21
  24. data/.rspec +0 -1
  25. data/.rubocop.yml +0 -148
  26. data/.rubocop_todo.yml +0 -35
  27. data/.simplecov +0 -4
  28. data/Gemfile +0 -13
  29. data/Rakefile +0 -2
  30. data/mock_redis.gemspec +0 -32
  31. data/spec/client_spec.rb +0 -36
  32. data/spec/cloning_spec.rb +0 -95
  33. data/spec/commands/append_spec.rb +0 -24
  34. data/spec/commands/auth_spec.rb +0 -7
  35. data/spec/commands/bgrewriteaof_spec.rb +0 -7
  36. data/spec/commands/bgsave_spec.rb +0 -7
  37. data/spec/commands/bitcount_spec.rb +0 -25
  38. data/spec/commands/bitfield_spec.rb +0 -169
  39. data/spec/commands/blpop_spec.rb +0 -53
  40. data/spec/commands/brpop_spec.rb +0 -59
  41. data/spec/commands/brpoplpush_spec.rb +0 -52
  42. data/spec/commands/connected_spec.rb +0 -7
  43. data/spec/commands/connection_spec.rb +0 -15
  44. data/spec/commands/dbsize_spec.rb +0 -18
  45. data/spec/commands/decr_spec.rb +0 -34
  46. data/spec/commands/decrby_spec.rb +0 -34
  47. data/spec/commands/del_spec.rb +0 -52
  48. data/spec/commands/disconnect_spec.rb +0 -7
  49. data/spec/commands/dump_spec.rb +0 -19
  50. data/spec/commands/echo_spec.rb +0 -11
  51. data/spec/commands/eval_spec.rb +0 -7
  52. data/spec/commands/evalsha_spec.rb +0 -10
  53. data/spec/commands/exists_spec.rb +0 -43
  54. data/spec/commands/expire_spec.rb +0 -111
  55. data/spec/commands/expireat_spec.rb +0 -47
  56. data/spec/commands/flushall_spec.rb +0 -38
  57. data/spec/commands/flushdb_spec.rb +0 -38
  58. data/spec/commands/future_spec.rb +0 -30
  59. data/spec/commands/geoadd_spec.rb +0 -58
  60. data/spec/commands/geodist_spec.rb +0 -118
  61. data/spec/commands/geohash_spec.rb +0 -52
  62. data/spec/commands/geopos_spec.rb +0 -55
  63. data/spec/commands/get_spec.rb +0 -31
  64. data/spec/commands/getbit_spec.rb +0 -34
  65. data/spec/commands/getdel.rb +0 -24
  66. data/spec/commands/getrange_spec.rb +0 -22
  67. data/spec/commands/getset_spec.rb +0 -23
  68. data/spec/commands/hdel_spec.rb +0 -77
  69. data/spec/commands/hexists_spec.rb +0 -27
  70. data/spec/commands/hget_spec.rb +0 -28
  71. data/spec/commands/hgetall_spec.rb +0 -32
  72. data/spec/commands/hincrby_spec.rb +0 -58
  73. data/spec/commands/hincrbyfloat_spec.rb +0 -58
  74. data/spec/commands/hkeys_spec.rb +0 -19
  75. data/spec/commands/hlen_spec.rb +0 -19
  76. data/spec/commands/hmget_spec.rb +0 -46
  77. data/spec/commands/hmset_spec.rb +0 -69
  78. data/spec/commands/hscan_each_spec.rb +0 -48
  79. data/spec/commands/hscan_spec.rb +0 -27
  80. data/spec/commands/hset_spec.rb +0 -42
  81. data/spec/commands/hsetnx_spec.rb +0 -44
  82. data/spec/commands/hvals_spec.rb +0 -19
  83. data/spec/commands/incr_spec.rb +0 -34
  84. data/spec/commands/incrby_spec.rb +0 -44
  85. data/spec/commands/incrbyfloat_spec.rb +0 -44
  86. data/spec/commands/info_spec.rb +0 -62
  87. data/spec/commands/keys_spec.rb +0 -139
  88. data/spec/commands/lastsave_spec.rb +0 -8
  89. data/spec/commands/lindex_spec.rb +0 -49
  90. data/spec/commands/linsert_spec.rb +0 -68
  91. data/spec/commands/llen_spec.rb +0 -16
  92. data/spec/commands/lpop_spec.rb +0 -35
  93. data/spec/commands/lpush_spec.rb +0 -43
  94. data/spec/commands/lpushx_spec.rb +0 -46
  95. data/spec/commands/lrange_spec.rb +0 -51
  96. data/spec/commands/lrem_spec.rb +0 -80
  97. data/spec/commands/lset_spec.rb +0 -43
  98. data/spec/commands/ltrim_spec.rb +0 -45
  99. data/spec/commands/mapped_hmget_spec.rb +0 -29
  100. data/spec/commands/mapped_hmset_spec.rb +0 -47
  101. data/spec/commands/mapped_mget_spec.rb +0 -22
  102. data/spec/commands/mapped_mset_spec.rb +0 -19
  103. data/spec/commands/mapped_msetnx_spec.rb +0 -26
  104. data/spec/commands/mget_spec.rb +0 -65
  105. data/spec/commands/move_spec.rb +0 -147
  106. data/spec/commands/mset_spec.rb +0 -43
  107. data/spec/commands/msetnx_spec.rb +0 -40
  108. data/spec/commands/persist_spec.rb +0 -48
  109. data/spec/commands/pexpire_spec.rb +0 -86
  110. data/spec/commands/pexpireat_spec.rb +0 -48
  111. data/spec/commands/ping_spec.rb +0 -11
  112. data/spec/commands/pipelined_spec.rb +0 -114
  113. data/spec/commands/psetex_spec.rb +0 -44
  114. data/spec/commands/pttl_spec.rb +0 -41
  115. data/spec/commands/quit_spec.rb +0 -7
  116. data/spec/commands/randomkey_spec.rb +0 -20
  117. data/spec/commands/rename_spec.rb +0 -42
  118. data/spec/commands/renamenx_spec.rb +0 -41
  119. data/spec/commands/restore_spec.rb +0 -47
  120. data/spec/commands/rpop_spec.rb +0 -35
  121. data/spec/commands/rpoplpush_spec.rb +0 -50
  122. data/spec/commands/rpush_spec.rb +0 -43
  123. data/spec/commands/rpushx_spec.rb +0 -46
  124. data/spec/commands/sadd_spec.rb +0 -45
  125. data/spec/commands/save_spec.rb +0 -7
  126. data/spec/commands/scan_each_spec.rb +0 -39
  127. data/spec/commands/scan_spec.rb +0 -64
  128. data/spec/commands/scard_spec.rb +0 -18
  129. data/spec/commands/script_spec.rb +0 -9
  130. data/spec/commands/sdiff_spec.rb +0 -47
  131. data/spec/commands/sdiffstore_spec.rb +0 -58
  132. data/spec/commands/select_spec.rb +0 -61
  133. data/spec/commands/set_spec.rb +0 -134
  134. data/spec/commands/setbit_spec.rb +0 -55
  135. data/spec/commands/setex_spec.rb +0 -38
  136. data/spec/commands/setnx_spec.rb +0 -25
  137. data/spec/commands/setrange_spec.rb +0 -30
  138. data/spec/commands/sinter_spec.rb +0 -39
  139. data/spec/commands/sinterstore_spec.rb +0 -53
  140. data/spec/commands/sismember_spec.rb +0 -29
  141. data/spec/commands/smembers_spec.rb +0 -28
  142. data/spec/commands/smove_spec.rb +0 -41
  143. data/spec/commands/sort_list_spec.rb +0 -21
  144. data/spec/commands/sort_set_spec.rb +0 -21
  145. data/spec/commands/sort_zset_spec.rb +0 -21
  146. data/spec/commands/spop_spec.rb +0 -40
  147. data/spec/commands/srandmember_spec.rb +0 -49
  148. data/spec/commands/srem_spec.rb +0 -45
  149. data/spec/commands/sscan_each_spec.rb +0 -48
  150. data/spec/commands/sscan_spec.rb +0 -39
  151. data/spec/commands/strlen_spec.rb +0 -18
  152. data/spec/commands/sunion_spec.rb +0 -42
  153. data/spec/commands/sunionstore_spec.rb +0 -59
  154. data/spec/commands/ttl_spec.rb +0 -40
  155. data/spec/commands/type_spec.rb +0 -36
  156. data/spec/commands/unwatch_spec.rb +0 -7
  157. data/spec/commands/watch_spec.rb +0 -21
  158. data/spec/commands/xadd_spec.rb +0 -122
  159. data/spec/commands/xlen_spec.rb +0 -22
  160. data/spec/commands/xrange_spec.rb +0 -164
  161. data/spec/commands/xread_spec.rb +0 -66
  162. data/spec/commands/xrevrange_spec.rb +0 -130
  163. data/spec/commands/xtrim_spec.rb +0 -36
  164. data/spec/commands/zadd_spec.rb +0 -129
  165. data/spec/commands/zcard_spec.rb +0 -19
  166. data/spec/commands/zcount_spec.rb +0 -39
  167. data/spec/commands/zincrby_spec.rb +0 -31
  168. data/spec/commands/zinterstore_spec.rb +0 -130
  169. data/spec/commands/zpopmax_spec.rb +0 -60
  170. data/spec/commands/zpopmin_spec.rb +0 -60
  171. data/spec/commands/zrange_spec.rb +0 -80
  172. data/spec/commands/zrangebyscore_spec.rb +0 -83
  173. data/spec/commands/zrank_spec.rb +0 -29
  174. data/spec/commands/zrem_spec.rb +0 -43
  175. data/spec/commands/zremrangebyrank_spec.rb +0 -27
  176. data/spec/commands/zremrangebyscore_spec.rb +0 -35
  177. data/spec/commands/zrevrange_spec.rb +0 -56
  178. data/spec/commands/zrevrangebyscore_spec.rb +0 -58
  179. data/spec/commands/zrevrank_spec.rb +0 -29
  180. data/spec/commands/zscan_each_spec.rb +0 -48
  181. data/spec/commands/zscan_spec.rb +0 -26
  182. data/spec/commands/zscore_spec.rb +0 -22
  183. data/spec/commands/zunionstore_spec.rb +0 -137
  184. data/spec/mock_redis_spec.rb +0 -93
  185. data/spec/spec_helper.rb +0 -74
  186. data/spec/support/redis_multiplexer.rb +0 -123
  187. data/spec/support/shared_examples/does_not_cleanup_empty_strings.rb +0 -14
  188. data/spec/support/shared_examples/only_operates_on_hashes.rb +0 -15
  189. data/spec/support/shared_examples/only_operates_on_lists.rb +0 -15
  190. data/spec/support/shared_examples/only_operates_on_sets.rb +0 -15
  191. data/spec/support/shared_examples/only_operates_on_strings.rb +0 -13
  192. data/spec/support/shared_examples/only_operates_on_zsets.rb +0 -59
  193. data/spec/support/shared_examples/sorts_enumerables.rb +0 -56
  194. data/spec/transactions_spec.rb +0 -163
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac517fcc81e569da0e5e0512027dd381ebd8c0553aaa9aa373ffb7be3afe983e
4
- data.tar.gz: 5e64b3ac11ab9c403165c082b8c2db641858ffd7430a6f6fd1c3c88c1d7b7090
3
+ metadata.gz: 1d7bda05082845039ee8e7aa688238c8006fb6754b5198e325e92723f4ec63bd
4
+ data.tar.gz: 430cd98257705509362934dc755f9e88820ebb1e7d39dee2a056ffd28c120d4d
5
5
  SHA512:
6
- metadata.gz: c4ab0e03ac161be256d4920837fe1cc70da6ae57f29b4e75c1f2eec404b46ad2efa5679552b089eddd3234d49eb85a8ec0f1a51cbfa118654da31a0c43f4c7cb
7
- data.tar.gz: 8c97fae25f874bdbbaedd52e0ac10bd793fae3cb711e7e6a368147301fbc653a35d0630e9c0ae172cc625b2b9c4f266d9d7dd08fe92441cfc5e04156d98a1ebd
6
+ metadata.gz: cff49225d6412aababaaad3cca42394764168862cc1c6d2b434fb83b5889582f0a74698b696e244036b695b318da0ea444cda16abe6e1ca73bfe9e2e3ab05ed9
7
+ data.tar.gz: 32cbd749e2180f56c1e779aedc726114c2aa242fe6d87e95a75f98d85b51814befea89c27f6cf6d7a1d306cb526236b9bf186b0aa1c541c4621969103c485691
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # MockRedis Changelog
2
2
 
3
+ ### 0.37.0
4
+
5
+ * Require Ruby 2.7 or newer, since Ruby 2.6 and older are EOL
6
+ * Remove unnecessary files from gem contents
7
+ * Add support for popping multiple items with `lpop`
8
+ * Add support for `scan` with type option
9
+ * Add support for `sadd?`
10
+ * Add support for scanning on keys containing hash tags (`{...}`)
11
+
12
+ ### 0.36.0
13
+
14
+ * Add support for `smismember`
15
+ * Add support for `lmove` and `blmove`
16
+ * Fix `zrem` to support passing array of integers
17
+
3
18
  ### 0.35.0
4
19
 
5
20
  * Add support for `getdel`
data/README.md CHANGED
@@ -10,7 +10,7 @@ for use in tests.
10
10
 
11
11
  ## Requirements
12
12
 
13
- Ruby 2.6+
13
+ Ruby 2.7+
14
14
 
15
15
  The current implementation is tested against Redis 6.2. Older versions may work, but can also return different results or not support some commands.
16
16
 
@@ -55,8 +55,8 @@ since it's an in-memory object confined to a single process. MockRedis
55
55
  makes every attempt to be Redis-compatible, but there are some
56
56
  necessary exceptions.
57
57
 
58
- * Blocking list commands (`#blpop`, `#brpop`, and `#brpoplpush`) work
59
- as expected if there is data for them to retrieve. If you use one of
58
+ * Blocking list commands (`#blmove`, `#blpop`, `#brpop`, and `#brpoplpush`)
59
+ work as expected if there is data for them to retrieve. If you use one of
60
60
  these commands with a nonzero timeout and there is no data for it to
61
61
  retrieve, then the command returns immediately. However, if you ask
62
62
  one of these commands for data with a 0 timeout (means "wait
@@ -336,7 +336,7 @@ class MockRedis
336
336
  def redis_pattern_to_ruby_regex(pattern)
337
337
  Regexp.new(
338
338
  "^#{pattern}$".
339
- gsub(/([+|()])/, '\\\\\1').
339
+ gsub(/([+|(){}])/, '\\\\\1').
340
340
  gsub(/(?<!\\)\?/, '\\1.').
341
341
  gsub(/([^\\])\*/, '\\1.*')
342
342
  )
@@ -93,7 +93,7 @@ class MockRedis
93
93
  def hmset(key, *kvpairs)
94
94
  if key.is_a? Array
95
95
  err_msg = 'ERR wrong number of arguments for \'hmset\' command'
96
- kvpairs = key[1..-1]
96
+ kvpairs = key[1..]
97
97
  key = key[0]
98
98
  end
99
99
 
@@ -6,6 +6,20 @@ class MockRedis
6
6
  include Assertions
7
7
  include UtilityMethods
8
8
 
9
+ def blmove(source, destination, wherefrom, whereto, options = {})
10
+ options = { :timeout => options } if options.is_a?(Integer)
11
+ timeout = options.is_a?(Hash) && options[:timeout] || 0
12
+ assert_valid_timeout(timeout)
13
+
14
+ if llen(source) > 0
15
+ lmove(source, destination, wherefrom, whereto)
16
+ elsif timeout > 0
17
+ nil
18
+ else
19
+ raise MockRedis::WouldBlock, "Can't block forever"
20
+ end
21
+ end
22
+
9
23
  def blpop(*args)
10
24
  lists, timeout = extract_timeout(args)
11
25
  nonempty_list = first_nonempty_list(lists)
@@ -78,8 +92,29 @@ class MockRedis
78
92
  with_list_at(key, &:length)
79
93
  end
80
94
 
81
- def lpop(key)
82
- with_list_at(key, &:shift)
95
+ def lmove(source, destination, wherefrom, whereto)
96
+ assert_listy(source)
97
+ assert_listy(destination)
98
+
99
+ wherefrom = wherefrom.to_s.downcase
100
+ whereto = whereto.to_s.downcase
101
+
102
+ unless %w[left right].include?(wherefrom) && %w[left right].include?(whereto)
103
+ raise Redis::CommandError, 'ERR syntax error'
104
+ end
105
+
106
+ value = wherefrom == 'left' ? lpop(source) : rpop(source)
107
+ (whereto == 'left' ? lpush(destination, value) : rpush(destination, value)) unless value.nil?
108
+ value
109
+ end
110
+
111
+ def lpop(key, count = nil)
112
+ return with_list_at(key, &:shift) if count.nil?
113
+
114
+ record_count = llen(key)
115
+ return nil if record_count.zero?
116
+
117
+ [record_count, count].min.times.map { with_list_at(key, &:shift) }
83
118
  end
84
119
 
85
120
  def lpush(key, values)
@@ -31,7 +31,7 @@ class MockRedis
31
31
 
32
32
  # Redis commands
33
33
  def flushall
34
- @databases.values.each(&:flushdb)
34
+ @databases.each_value(&:flushdb)
35
35
  'OK'
36
36
  end
37
37
 
@@ -41,22 +41,20 @@ class MockRedis
41
41
  end
42
42
 
43
43
  responses = @pipelined_futures.flat_map do |future|
44
- begin
45
- result = if future.block
46
- send(*future.command, &future.block)
47
- else
48
- send(*future.command)
49
- end
50
- future.store_result(result)
44
+ result = if future.block
45
+ send(*future.command, &future.block)
46
+ else
47
+ send(*future.command)
48
+ end
49
+ future.store_result(result)
51
50
 
52
- if future.block
53
- result
54
- else
55
- [result]
56
- end
57
- rescue StandardError => e
58
- e
51
+ if future.block
52
+ result
53
+ else
54
+ [result]
59
55
  end
56
+ rescue StandardError => e
57
+ e
60
58
  end
61
59
  @pipelined_futures = []
62
60
  responses
@@ -27,6 +27,11 @@ class MockRedis
27
27
  end
28
28
  end
29
29
 
30
+ def sadd?(key, members)
31
+ res = sadd(key, members)
32
+ res.is_a?(Numeric) ? res > 0 : res
33
+ end
34
+
30
35
  def scard(key)
31
36
  with_set_at(key, &:length)
32
37
  end
@@ -64,6 +69,12 @@ class MockRedis
64
69
  with_set_at(key) { |s| s.include?(member.to_s) }
65
70
  end
66
71
 
72
+ def smismember(key, *members)
73
+ with_set_at(key) do |set|
74
+ members.flatten.map { |m| set.include?(m.to_s) }
75
+ end
76
+ end
77
+
67
78
  def smembers(key)
68
79
  with_set_at(key, &:to_a).map(&:dup).reverse
69
80
  end
@@ -165,7 +176,7 @@ class MockRedis
165
176
  with_set_at(keys.first, &blk)
166
177
  else
167
178
  with_set_at(keys.first) do |set|
168
- with_sets_at(*(keys[1..-1])) do |*sets|
179
+ with_sets_at(*(keys[1..])) do |*sets|
169
180
  yield(*([set] + sets))
170
181
  end
171
182
  end
@@ -37,7 +37,7 @@ class MockRedis
37
37
  @members = if count == 0
38
38
  Set.new
39
39
  else
40
- @members.to_a[-count..-1].to_set
40
+ @members.to_a[-count..].to_set
41
41
  end
42
42
  deleted
43
43
  else
@@ -71,8 +71,8 @@ class MockRedis
71
71
  items
72
72
  end
73
73
 
74
- def each
75
- members.each { |m| yield m }
74
+ def each(&block)
75
+ members.each(&block)
76
76
  end
77
77
 
78
78
  private
@@ -38,7 +38,7 @@ class MockRedis
38
38
  type, offset = args.shift(2)
39
39
 
40
40
  is_signed = type.slice(0) == 'i'
41
- type_size = type[1..-1].to_i
41
+ type_size = type[1..].to_i
42
42
 
43
43
  if (type_size > 64 && is_signed) || (type_size >= 64 && !is_signed)
44
44
  raise Redis::CommandError,
@@ -47,7 +47,7 @@ class MockRedis
47
47
  end
48
48
 
49
49
  if offset.to_s[0] == '#'
50
- offset = offset[1..-1].to_i * type_size
50
+ offset = offset[1..].to_i * type_size
51
51
  end
52
52
 
53
53
  bits = []
@@ -365,7 +365,7 @@ class MockRedis
365
365
  old_value = (data[key] || '')
366
366
 
367
367
  prefix = zero_pad(old_value[0...offset], offset)
368
- data[key] = prefix + value + (old_value[(offset + value.length)..-1] || '')
368
+ data[key] = prefix + value + (old_value[(offset + value.length)..] || '')
369
369
  data[key].length
370
370
  end
371
371
 
@@ -57,13 +57,11 @@ class MockRedis
57
57
  @multi_block_given = false
58
58
 
59
59
  responses = @transaction_futures.map do |future|
60
- begin
61
- result = send(*future.command)
62
- future.store_result(result)
63
- future.value
64
- rescue StandardError => e
65
- e
66
- end
60
+ result = send(*future.command)
61
+ future.store_result(result)
62
+ future.value
63
+ rescue StandardError => e
64
+ e
67
65
  end
68
66
 
69
67
  @transaction_futures = []
@@ -28,6 +28,7 @@ class MockRedis
28
28
  cursor = cursor.to_i
29
29
  match = opts[:match] || '*'
30
30
  key = opts[:key] || lambda { |x| x }
31
+ type_opt = opts[:type]
31
32
  filtered_values = []
32
33
 
33
34
  limit = cursor + count
@@ -35,7 +36,8 @@ class MockRedis
35
36
 
36
37
  unless values[cursor...limit].nil?
37
38
  filtered_values = values[cursor...limit].select do |val|
38
- redis_pattern_to_ruby_regex(match).match(key.call(val))
39
+ redis_pattern_to_ruby_regex(match).match(key.call(val)) &&
40
+ (type_opt.nil? || type(val) == type_opt)
39
41
  end
40
42
  end
41
43
 
@@ -68,7 +70,7 @@ class MockRedis
68
70
  end
69
71
 
70
72
  def left_pad(str, size)
71
- str = '0' + str while str.length < size
73
+ str = "0#{str}" while str.length < size
72
74
 
73
75
  str
74
76
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  class MockRedis
5
- VERSION = '0.35.0'
5
+ VERSION = '0.37.0'
6
6
  end
@@ -10,9 +10,11 @@ class MockRedis
10
10
 
11
11
  def_delegators :members, :empty?, :include?, :size
12
12
 
13
- def initialize
13
+ def initialize(enum = nil)
14
14
  @members = Set.new
15
- @scores = {}
15
+ @members.merge(enum) if enum
16
+
17
+ @scores = {}
16
18
  end
17
19
 
18
20
  def initialize_copy(source)
@@ -26,7 +26,7 @@ class MockRedis
26
26
  end
27
27
 
28
28
  def zadd_one_member(key, score, member, zadd_options = {})
29
- assert_scorey(score) unless score.to_s =~ /(\+|\-)inf/
29
+ assert_scorey(score) unless score.to_s =~ /(\+|-)inf/
30
30
 
31
31
  with_zset_at(key) do |zset|
32
32
  if zadd_options[:incr]
@@ -147,7 +147,7 @@ class MockRedis
147
147
  else
148
148
  retval = args.map { |member| !!zscore(key, member.to_s) }.count(true)
149
149
  with_zset_at(key) do |z|
150
- args.each { |member| z.delete?(member) }
150
+ args.each { |member| z.delete?(member.to_s) }
151
151
  end
152
152
  end
153
153
  end
@@ -316,7 +316,7 @@ class MockRedis
316
316
  with_zset_at(keys.first, coercible: coercible, &blk)
317
317
  else
318
318
  with_zset_at(keys.first, coercible: coercible) do |set|
319
- with_zsets_at(*(keys[1..-1]), coercible: coercible) do |*sets|
319
+ with_zsets_at(*(keys[1..]), coercible: coercible) do |*sets|
320
320
  yield(*([set] + sets))
321
321
  end
322
322
  end
@@ -351,7 +351,7 @@ class MockRedis
351
351
  end
352
352
 
353
353
  def assert_scorey(value, message = 'ERR value is not a valid float')
354
- return if value.to_s =~ /\(?(\-|\+)inf/
354
+ return if value.to_s =~ /\(?(-|\+)inf/
355
355
 
356
356
  value = $1 if value.to_s =~ /\((.*)/
357
357
  unless looks_like_float?(value)
data/lib/mock_redis.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'set'
2
- require 'ruby2_keywords'
3
2
 
4
3
  require 'mock_redis/assertions'
5
4
  require 'mock_redis/database'
@@ -130,7 +129,7 @@ class MockRedis
130
129
  defaults[:host] = uri.host
131
130
  defaults[:port] = uri.port if uri.port
132
131
  defaults[:password] = uri.password if uri.password
133
- defaults[:db] = uri.path[1..-1].to_i if uri.path
132
+ defaults[:db] = uri.path[1..].to_i if uri.path
134
133
  end
135
134
  end
136
135