mock_redis 0.20.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -5
  3. data/.rubocop_todo.yml +1 -1
  4. data/.travis.yml +3 -3
  5. data/CHANGELOG.md +37 -0
  6. data/Gemfile +2 -2
  7. data/LICENSE.md +21 -0
  8. data/README.md +37 -13
  9. data/lib/mock_redis.rb +0 -5
  10. data/lib/mock_redis/database.rb +53 -17
  11. data/lib/mock_redis/future.rb +1 -1
  12. data/lib/mock_redis/geospatial_methods.rb +4 -4
  13. data/lib/mock_redis/hash_methods.rb +22 -14
  14. data/lib/mock_redis/info_method.rb +2 -2
  15. data/lib/mock_redis/multi_db_wrapper.rb +2 -2
  16. data/lib/mock_redis/set_methods.rb +1 -0
  17. data/lib/mock_redis/stream.rb +22 -2
  18. data/lib/mock_redis/stream/id.rb +1 -1
  19. data/lib/mock_redis/stream_methods.rb +14 -1
  20. data/lib/mock_redis/string_methods.rb +28 -13
  21. data/lib/mock_redis/transaction_wrapper.rb +2 -2
  22. data/lib/mock_redis/utility_methods.rb +6 -3
  23. data/lib/mock_redis/version.rb +1 -1
  24. data/lib/mock_redis/zset_methods.rb +52 -9
  25. data/mock_redis.gemspec +1 -2
  26. data/spec/client_spec.rb +12 -0
  27. data/spec/commands/blpop_spec.rb +0 -6
  28. data/spec/commands/brpop_spec.rb +6 -5
  29. data/spec/commands/del_spec.rb +15 -0
  30. data/spec/commands/dump_spec.rb +19 -0
  31. data/spec/commands/exists_spec.rb +34 -5
  32. data/spec/commands/future_spec.rb +11 -1
  33. data/spec/commands/geoadd_spec.rb +1 -1
  34. data/spec/commands/hdel_spec.rb +16 -0
  35. data/spec/commands/hmset_spec.rb +26 -0
  36. data/spec/commands/hset_spec.rb +6 -6
  37. data/spec/commands/keys_spec.rb +17 -0
  38. data/spec/commands/mget_spec.rb +6 -0
  39. data/spec/commands/move_spec.rb +5 -5
  40. data/spec/commands/pipelined_spec.rb +20 -0
  41. data/spec/commands/restore_spec.rb +47 -0
  42. data/spec/commands/scan_spec.rb +9 -0
  43. data/spec/commands/set_spec.rb +12 -2
  44. data/spec/commands/setbit_spec.rb +1 -0
  45. data/spec/commands/setex_spec.rb +16 -0
  46. data/spec/commands/srandmember_spec.rb +1 -1
  47. data/spec/commands/srem_spec.rb +5 -0
  48. data/spec/commands/xadd_spec.rb +20 -0
  49. data/spec/commands/xrange_spec.rb +13 -0
  50. data/spec/commands/xread_spec.rb +50 -0
  51. data/spec/commands/xtrim_spec.rb +6 -0
  52. data/spec/commands/zinterstore_spec.rb +34 -0
  53. data/spec/commands/zpopmax_spec.rb +60 -0
  54. data/spec/commands/zpopmin_spec.rb +60 -0
  55. data/spec/commands/zrange_spec.rb +1 -1
  56. data/spec/commands/zrangebyscore_spec.rb +1 -1
  57. data/spec/commands/zrevrange_spec.rb +1 -1
  58. data/spec/commands/zrevrangebyscore_spec.rb +1 -1
  59. data/spec/commands/zunionstore_spec.rb +33 -0
  60. data/spec/mock_redis_spec.rb +4 -6
  61. data/spec/spec_helper.rb +4 -2
  62. data/spec/support/redis_multiplexer.rb +1 -0
  63. data/spec/transactions_spec.rb +16 -0
  64. metadata +16 -26
  65. data/LICENSE +0 -19
@@ -9,6 +9,7 @@ class RedisMultiplexer < BlankSlate
9
9
 
10
10
  def initialize(*a)
11
11
  @mock_redis = MockRedis.new(*a)
12
+ Redis.exists_returns_integer = true
12
13
  @real_redis = Redis.new(*a)
13
14
  _gsub_clear
14
15
  end
@@ -67,6 +67,22 @@ describe 'transactions (multi/exec/discard)' do
67
67
  @redises.get('counter').should eq '6'
68
68
  @redises.get('test').should eq '1'
69
69
  end
70
+
71
+ it 'allows blocks within multi blocks' do
72
+ @redises.set('foo', 'bar')
73
+ @redises.set('fuu', 'baz')
74
+
75
+ result = nil
76
+
77
+ @redises.multi do |r|
78
+ result = r.mget('foo', 'fuu') { |reply| reply.map(&:upcase) }
79
+ r.del('foo', 'fuu')
80
+ end
81
+
82
+ result.value.should eq %w[BAR BAZ]
83
+ @redises.get('foo').should eq nil
84
+ @redises.get('fuu').should eq nil
85
+ end
70
86
  end
71
87
 
72
88
  context '#discard' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
@@ -9,42 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-05-03 00:00:00.000000000 Z
12
+ date: 2020-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '10'
21
- - - "<"
22
- - !ruby/object:Gem::Version
23
- version: '12'
24
- type: :development
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- version: '10'
31
- - - "<"
32
- - !ruby/object:Gem::Version
33
- version: '12'
34
14
  - !ruby/object:Gem::Dependency
35
15
  name: redis
36
16
  requirement: !ruby/object:Gem::Requirement
37
17
  requirements:
38
18
  - - "~>"
39
19
  - !ruby/object:Gem::Version
40
- version: 4.1.0
20
+ version: 4.2.0
41
21
  type: :development
42
22
  prerelease: false
43
23
  version_requirements: !ruby/object:Gem::Requirement
44
24
  requirements:
45
25
  - - "~>"
46
26
  - !ruby/object:Gem::Version
47
- version: 4.1.0
27
+ version: 4.2.0
48
28
  - !ruby/object:Gem::Dependency
49
29
  name: rspec
50
30
  requirement: !ruby/object:Gem::Requirement
@@ -105,7 +85,7 @@ files:
105
85
  - ".travis.yml"
106
86
  - CHANGELOG.md
107
87
  - Gemfile
108
- - LICENSE
88
+ - LICENSE.md
109
89
  - README.md
110
90
  - Rakefile
111
91
  - lib/mock_redis.rb
@@ -151,6 +131,7 @@ files:
151
131
  - spec/commands/decrby_spec.rb
152
132
  - spec/commands/del_spec.rb
153
133
  - spec/commands/disconnect_spec.rb
134
+ - spec/commands/dump_spec.rb
154
135
  - spec/commands/echo_spec.rb
155
136
  - spec/commands/eval_spec.rb
156
137
  - spec/commands/evalsha_spec.rb
@@ -218,6 +199,7 @@ files:
218
199
  - spec/commands/randomkey_spec.rb
219
200
  - spec/commands/rename_spec.rb
220
201
  - spec/commands/renamenx_spec.rb
202
+ - spec/commands/restore_spec.rb
221
203
  - spec/commands/rpop_spec.rb
222
204
  - spec/commands/rpoplpush_spec.rb
223
205
  - spec/commands/rpush_spec.rb
@@ -259,6 +241,7 @@ files:
259
241
  - spec/commands/xadd_spec.rb
260
242
  - spec/commands/xlen_spec.rb
261
243
  - spec/commands/xrange_spec.rb
244
+ - spec/commands/xread_spec.rb
262
245
  - spec/commands/xrevrange_spec.rb
263
246
  - spec/commands/xtrim_spec.rb
264
247
  - spec/commands/zadd_spec.rb
@@ -266,6 +249,8 @@ files:
266
249
  - spec/commands/zcount_spec.rb
267
250
  - spec/commands/zincrby_spec.rb
268
251
  - spec/commands/zinterstore_spec.rb
252
+ - spec/commands/zpopmax_spec.rb
253
+ - spec/commands/zpopmin_spec.rb
269
254
  - spec/commands/zrange_spec.rb
270
255
  - spec/commands/zrangebyscore_spec.rb
271
256
  - spec/commands/zrank_spec.rb
@@ -309,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
294
  - !ruby/object:Gem::Version
310
295
  version: '0'
311
296
  requirements: []
312
- rubygems_version: 3.0.3
297
+ rubygems_version: 3.1.1
313
298
  signing_key:
314
299
  specification_version: 4
315
300
  summary: Redis mock that just lives in memory; useful for testing.
@@ -331,6 +316,7 @@ test_files:
331
316
  - spec/commands/decrby_spec.rb
332
317
  - spec/commands/del_spec.rb
333
318
  - spec/commands/disconnect_spec.rb
319
+ - spec/commands/dump_spec.rb
334
320
  - spec/commands/echo_spec.rb
335
321
  - spec/commands/eval_spec.rb
336
322
  - spec/commands/evalsha_spec.rb
@@ -398,6 +384,7 @@ test_files:
398
384
  - spec/commands/randomkey_spec.rb
399
385
  - spec/commands/rename_spec.rb
400
386
  - spec/commands/renamenx_spec.rb
387
+ - spec/commands/restore_spec.rb
401
388
  - spec/commands/rpop_spec.rb
402
389
  - spec/commands/rpoplpush_spec.rb
403
390
  - spec/commands/rpush_spec.rb
@@ -439,6 +426,7 @@ test_files:
439
426
  - spec/commands/xadd_spec.rb
440
427
  - spec/commands/xlen_spec.rb
441
428
  - spec/commands/xrange_spec.rb
429
+ - spec/commands/xread_spec.rb
442
430
  - spec/commands/xrevrange_spec.rb
443
431
  - spec/commands/xtrim_spec.rb
444
432
  - spec/commands/zadd_spec.rb
@@ -446,6 +434,8 @@ test_files:
446
434
  - spec/commands/zcount_spec.rb
447
435
  - spec/commands/zincrby_spec.rb
448
436
  - spec/commands/zinterstore_spec.rb
437
+ - spec/commands/zpopmax_spec.rb
438
+ - spec/commands/zpopmin_spec.rb
449
439
  - spec/commands/zrange_spec.rb
450
440
  - spec/commands/zrangebyscore_spec.rb
451
441
  - spec/commands/zrank_spec.rb
data/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2011 Philotic, Inc.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.