mock_redis 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +1 -1
  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 +7 -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 +6 -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 +3 -3
  17. data/lib/mock_redis.rb +1 -2
  18. metadata +19 -360
  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/blmove_spec.rb +0 -52
  40. data/spec/commands/blpop_spec.rb +0 -53
  41. data/spec/commands/brpop_spec.rb +0 -59
  42. data/spec/commands/brpoplpush_spec.rb +0 -52
  43. data/spec/commands/connected_spec.rb +0 -7
  44. data/spec/commands/connection_spec.rb +0 -15
  45. data/spec/commands/dbsize_spec.rb +0 -18
  46. data/spec/commands/decr_spec.rb +0 -34
  47. data/spec/commands/decrby_spec.rb +0 -34
  48. data/spec/commands/del_spec.rb +0 -52
  49. data/spec/commands/disconnect_spec.rb +0 -7
  50. data/spec/commands/dump_spec.rb +0 -19
  51. data/spec/commands/echo_spec.rb +0 -11
  52. data/spec/commands/eval_spec.rb +0 -7
  53. data/spec/commands/evalsha_spec.rb +0 -10
  54. data/spec/commands/exists_spec.rb +0 -43
  55. data/spec/commands/expire_spec.rb +0 -111
  56. data/spec/commands/expireat_spec.rb +0 -47
  57. data/spec/commands/flushall_spec.rb +0 -38
  58. data/spec/commands/flushdb_spec.rb +0 -38
  59. data/spec/commands/future_spec.rb +0 -30
  60. data/spec/commands/geoadd_spec.rb +0 -58
  61. data/spec/commands/geodist_spec.rb +0 -118
  62. data/spec/commands/geohash_spec.rb +0 -52
  63. data/spec/commands/geopos_spec.rb +0 -55
  64. data/spec/commands/get_spec.rb +0 -31
  65. data/spec/commands/getbit_spec.rb +0 -34
  66. data/spec/commands/getdel.rb +0 -24
  67. data/spec/commands/getrange_spec.rb +0 -22
  68. data/spec/commands/getset_spec.rb +0 -23
  69. data/spec/commands/hdel_spec.rb +0 -77
  70. data/spec/commands/hexists_spec.rb +0 -27
  71. data/spec/commands/hget_spec.rb +0 -28
  72. data/spec/commands/hgetall_spec.rb +0 -32
  73. data/spec/commands/hincrby_spec.rb +0 -58
  74. data/spec/commands/hincrbyfloat_spec.rb +0 -58
  75. data/spec/commands/hkeys_spec.rb +0 -19
  76. data/spec/commands/hlen_spec.rb +0 -19
  77. data/spec/commands/hmget_spec.rb +0 -46
  78. data/spec/commands/hmset_spec.rb +0 -69
  79. data/spec/commands/hscan_each_spec.rb +0 -48
  80. data/spec/commands/hscan_spec.rb +0 -27
  81. data/spec/commands/hset_spec.rb +0 -42
  82. data/spec/commands/hsetnx_spec.rb +0 -44
  83. data/spec/commands/hvals_spec.rb +0 -19
  84. data/spec/commands/incr_spec.rb +0 -34
  85. data/spec/commands/incrby_spec.rb +0 -44
  86. data/spec/commands/incrbyfloat_spec.rb +0 -44
  87. data/spec/commands/info_spec.rb +0 -62
  88. data/spec/commands/keys_spec.rb +0 -139
  89. data/spec/commands/lastsave_spec.rb +0 -8
  90. data/spec/commands/lindex_spec.rb +0 -49
  91. data/spec/commands/linsert_spec.rb +0 -68
  92. data/spec/commands/llen_spec.rb +0 -16
  93. data/spec/commands/lmove_spec.rb +0 -72
  94. data/spec/commands/lpop_spec.rb +0 -35
  95. data/spec/commands/lpush_spec.rb +0 -43
  96. data/spec/commands/lpushx_spec.rb +0 -46
  97. data/spec/commands/lrange_spec.rb +0 -51
  98. data/spec/commands/lrem_spec.rb +0 -80
  99. data/spec/commands/lset_spec.rb +0 -43
  100. data/spec/commands/ltrim_spec.rb +0 -45
  101. data/spec/commands/mapped_hmget_spec.rb +0 -29
  102. data/spec/commands/mapped_hmset_spec.rb +0 -47
  103. data/spec/commands/mapped_mget_spec.rb +0 -22
  104. data/spec/commands/mapped_mset_spec.rb +0 -19
  105. data/spec/commands/mapped_msetnx_spec.rb +0 -26
  106. data/spec/commands/mget_spec.rb +0 -65
  107. data/spec/commands/move_spec.rb +0 -147
  108. data/spec/commands/mset_spec.rb +0 -43
  109. data/spec/commands/msetnx_spec.rb +0 -40
  110. data/spec/commands/persist_spec.rb +0 -48
  111. data/spec/commands/pexpire_spec.rb +0 -86
  112. data/spec/commands/pexpireat_spec.rb +0 -48
  113. data/spec/commands/ping_spec.rb +0 -11
  114. data/spec/commands/pipelined_spec.rb +0 -114
  115. data/spec/commands/psetex_spec.rb +0 -44
  116. data/spec/commands/pttl_spec.rb +0 -41
  117. data/spec/commands/quit_spec.rb +0 -7
  118. data/spec/commands/randomkey_spec.rb +0 -20
  119. data/spec/commands/rename_spec.rb +0 -42
  120. data/spec/commands/renamenx_spec.rb +0 -41
  121. data/spec/commands/restore_spec.rb +0 -47
  122. data/spec/commands/rpop_spec.rb +0 -35
  123. data/spec/commands/rpoplpush_spec.rb +0 -50
  124. data/spec/commands/rpush_spec.rb +0 -43
  125. data/spec/commands/rpushx_spec.rb +0 -46
  126. data/spec/commands/sadd_spec.rb +0 -45
  127. data/spec/commands/save_spec.rb +0 -7
  128. data/spec/commands/scan_each_spec.rb +0 -39
  129. data/spec/commands/scan_spec.rb +0 -64
  130. data/spec/commands/scard_spec.rb +0 -18
  131. data/spec/commands/script_spec.rb +0 -9
  132. data/spec/commands/sdiff_spec.rb +0 -47
  133. data/spec/commands/sdiffstore_spec.rb +0 -58
  134. data/spec/commands/select_spec.rb +0 -61
  135. data/spec/commands/set_spec.rb +0 -134
  136. data/spec/commands/setbit_spec.rb +0 -55
  137. data/spec/commands/setex_spec.rb +0 -38
  138. data/spec/commands/setnx_spec.rb +0 -25
  139. data/spec/commands/setrange_spec.rb +0 -30
  140. data/spec/commands/sinter_spec.rb +0 -39
  141. data/spec/commands/sinterstore_spec.rb +0 -53
  142. data/spec/commands/sismember_spec.rb +0 -29
  143. data/spec/commands/smembers_spec.rb +0 -28
  144. data/spec/commands/smismember_spec.rb +0 -34
  145. data/spec/commands/smove_spec.rb +0 -41
  146. data/spec/commands/sort_list_spec.rb +0 -21
  147. data/spec/commands/sort_set_spec.rb +0 -21
  148. data/spec/commands/sort_zset_spec.rb +0 -21
  149. data/spec/commands/spop_spec.rb +0 -40
  150. data/spec/commands/srandmember_spec.rb +0 -49
  151. data/spec/commands/srem_spec.rb +0 -45
  152. data/spec/commands/sscan_each_spec.rb +0 -48
  153. data/spec/commands/sscan_spec.rb +0 -39
  154. data/spec/commands/strlen_spec.rb +0 -18
  155. data/spec/commands/sunion_spec.rb +0 -42
  156. data/spec/commands/sunionstore_spec.rb +0 -59
  157. data/spec/commands/ttl_spec.rb +0 -40
  158. data/spec/commands/type_spec.rb +0 -36
  159. data/spec/commands/unwatch_spec.rb +0 -7
  160. data/spec/commands/watch_spec.rb +0 -21
  161. data/spec/commands/xadd_spec.rb +0 -122
  162. data/spec/commands/xlen_spec.rb +0 -22
  163. data/spec/commands/xrange_spec.rb +0 -164
  164. data/spec/commands/xread_spec.rb +0 -66
  165. data/spec/commands/xrevrange_spec.rb +0 -130
  166. data/spec/commands/xtrim_spec.rb +0 -36
  167. data/spec/commands/zadd_spec.rb +0 -129
  168. data/spec/commands/zcard_spec.rb +0 -19
  169. data/spec/commands/zcount_spec.rb +0 -39
  170. data/spec/commands/zincrby_spec.rb +0 -31
  171. data/spec/commands/zinterstore_spec.rb +0 -130
  172. data/spec/commands/zpopmax_spec.rb +0 -60
  173. data/spec/commands/zpopmin_spec.rb +0 -60
  174. data/spec/commands/zrange_spec.rb +0 -80
  175. data/spec/commands/zrangebyscore_spec.rb +0 -83
  176. data/spec/commands/zrank_spec.rb +0 -29
  177. data/spec/commands/zrem_spec.rb +0 -50
  178. data/spec/commands/zremrangebyrank_spec.rb +0 -27
  179. data/spec/commands/zremrangebyscore_spec.rb +0 -35
  180. data/spec/commands/zrevrange_spec.rb +0 -56
  181. data/spec/commands/zrevrangebyscore_spec.rb +0 -58
  182. data/spec/commands/zrevrank_spec.rb +0 -29
  183. data/spec/commands/zscan_each_spec.rb +0 -48
  184. data/spec/commands/zscan_spec.rb +0 -26
  185. data/spec/commands/zscore_spec.rb +0 -22
  186. data/spec/commands/zunionstore_spec.rb +0 -137
  187. data/spec/mock_redis_spec.rb +0 -93
  188. data/spec/spec_helper.rb +0 -74
  189. data/spec/support/redis_multiplexer.rb +0 -123
  190. data/spec/support/shared_examples/does_not_cleanup_empty_strings.rb +0 -14
  191. data/spec/support/shared_examples/only_operates_on_hashes.rb +0 -15
  192. data/spec/support/shared_examples/only_operates_on_lists.rb +0 -15
  193. data/spec/support/shared_examples/only_operates_on_sets.rb +0 -15
  194. data/spec/support/shared_examples/only_operates_on_strings.rb +0 -13
  195. data/spec/support/shared_examples/only_operates_on_zsets.rb +0 -59
  196. data/spec/support/shared_examples/sorts_enumerables.rb +0 -56
  197. data/spec/transactions_spec.rb +0 -163
data/.rubocop.yml DELETED
@@ -1,148 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- AllCops:
4
- TargetRubyVersion: 2.4
5
-
6
- Layout/ArgumentAlignment:
7
- Enabled: false
8
-
9
- Layout/ParameterAlignment:
10
- Enabled: false
11
-
12
- Layout/DotPosition:
13
- Enabled: false
14
-
15
- Layout/EmptyLineAfterGuardClause:
16
- Enabled: false
17
-
18
- Layout/LineLength:
19
- Max: 100
20
-
21
- Layout/SpaceAroundMethodCallOperator:
22
- Enabled: true
23
-
24
- Lint/AssignmentInCondition:
25
- Enabled: false
26
-
27
- Lint/RaiseException:
28
- Enabled: true
29
-
30
- Lint/StructNewOverride:
31
- Enabled: true
32
-
33
- # We use this a lot in specs where it's perfectly valid
34
- Lint/Void:
35
- Exclude:
36
- - spec/**/*
37
-
38
- Metrics/AbcSize:
39
- Enabled: false
40
-
41
- Metrics/BlockLength:
42
- Enabled: false
43
-
44
- Metrics/CyclomaticComplexity:
45
- Enabled: false
46
-
47
- Metrics/ClassLength:
48
- Enabled: false
49
-
50
- Metrics/MethodLength:
51
- Enabled: false
52
-
53
- Metrics/ModuleLength:
54
- Enabled: false
55
-
56
- Metrics/PerceivedComplexity:
57
- Enabled: false
58
-
59
- # This hides the has-a versus is-a relationship indicated by the method name
60
- Naming/PredicateName:
61
- Enabled: false
62
-
63
- Style/Documentation:
64
- Enabled: false
65
-
66
- Style/DoubleNegation:
67
- Enabled: false
68
-
69
- Style/ExponentialNotation:
70
- Enabled: true
71
-
72
- Style/HashEachMethods:
73
- Enabled: true
74
-
75
- Style/HashTransformKeys:
76
- Enabled: true
77
-
78
- Style/HashTransformValues:
79
- Enabled: true
80
-
81
- # We have too much code that relies on modifying strings
82
- Style/FrozenStringLiteralComment:
83
- Enabled: false
84
-
85
- Style/GuardClause:
86
- Enabled: false
87
-
88
- Style/HashSyntax:
89
- Enabled: false
90
-
91
- Style/IfUnlessModifier:
92
- Enabled: false
93
-
94
- Style/Lambda:
95
- Enabled: false
96
-
97
- # TODO: Address these at some point
98
- Style/MethodMissingSuper:
99
- Enabled: false
100
-
101
- Style/MissingRespondToMissing:
102
- Enabled: false
103
-
104
- Style/MultilineBlockChain:
105
- Enabled: false
106
-
107
- Style/NumericPredicate:
108
- Enabled: false
109
-
110
- # Prefer curly braces except for %i/%w/%W, since those return arrays.
111
- Style/PercentLiteralDelimiters:
112
- PreferredDelimiters:
113
- '%': '{}'
114
- '%i': '[]'
115
- '%q': '{}'
116
- '%Q': '{}'
117
- '%r': '{}'
118
- '%s': '()'
119
- '%w': '[]'
120
- '%W': '[]'
121
- '%x': '{}'
122
-
123
- Style/PerlBackrefs:
124
- Enabled: false
125
-
126
- Style/RescueModifier:
127
- Enabled: false
128
-
129
- Style/SignalException:
130
- Enabled: false
131
-
132
- Style/SingleLineBlockParams:
133
- Enabled: false
134
-
135
- Style/SymbolArray:
136
- Enabled: false
137
-
138
- Style/TrailingCommaInArguments:
139
- Enabled: false
140
-
141
- Style/TrailingCommaInArrayLiteral:
142
- Enabled: false
143
-
144
- Style/TrailingCommaInHashLiteral:
145
- Enabled: false
146
-
147
- Style/WhenThen:
148
- Enabled: false
data/.rubocop_todo.yml DELETED
@@ -1,35 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-08-03 11:15:53 -0700 using RuboCop version 0.58.2.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 17
10
- # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
11
- # AllowedNames: io, id, to, by, on, in, at, ip
12
- Naming/MethodParameterName:
13
- Exclude:
14
- - 'lib/mock_redis/database.rb'
15
- - 'lib/mock_redis/expire_wrapper.rb'
16
- - 'lib/mock_redis/geospatial_methods.rb'
17
- - 'lib/mock_redis/multi_db_wrapper.rb'
18
- - 'lib/mock_redis/pipelined_wrapper.rb'
19
- - 'lib/mock_redis/string_methods.rb'
20
- - 'lib/mock_redis/transaction_wrapper.rb'
21
- - 'lib/mock_redis/utility_methods.rb'
22
- - 'lib/mock_redis/zset_methods.rb'
23
- - 'spec/support/redis_multiplexer.rb'
24
-
25
- # Offense count: 2
26
- # Configuration parameters: EnforcedStyle.
27
- # SupportedStyles: inline, group
28
- Style/AccessModifierDeclarations:
29
- Exclude:
30
- - 'lib/mock_redis/zset_methods.rb'
31
-
32
- # Offense count: 1
33
- Style/DateTime:
34
- Exclude:
35
- - 'spec/commands/zremrangebyscore_spec.rb'
data/.simplecov DELETED
@@ -1,4 +0,0 @@
1
- SimpleCov.start do
2
- add_filter '/bin/'
3
- add_filter '/spec/'
4
- end
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- # Specify your gem's dependencies in mock_redis.gemspec
4
- gemspec
5
-
6
- # Run all pre-commit hooks via Overcommit during CI runs
7
- gem 'overcommit', '0.53.0'
8
-
9
- # Pin tool versions (which are executed by Overcommit) for Travis builds
10
- gem 'rubocop', '0.82.0'
11
-
12
- gem 'simplecov', '~> 0.21.0'
13
- gem 'simplecov-lcov', '~> 0.8.0'
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
data/mock_redis.gemspec DELETED
@@ -1,32 +0,0 @@
1
- $LOAD_PATH << File.expand_path('lib', __dir__)
2
- require 'mock_redis/version'
3
-
4
- Gem::Specification.new do |s|
5
- s.name = 'mock_redis'
6
- s.version = MockRedis::VERSION
7
- s.license = 'MIT'
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Shane da Silva', 'Samuel Merritt']
10
- s.email = ['shane@dasilva.io']
11
- s.homepage = 'https://github.com/sds/mock_redis'
12
- s.summary = 'Redis mock that just lives in memory; useful for testing.'
13
-
14
- s.description = <<-MSG.strip.gsub(/\s+/, ' ')
15
- Instantiate one with `redis = MockRedis.new` and treat it like you would a
16
- normal Redis object. It supports all the usual Redis operations.
17
- MSG
18
-
19
- s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- spec/*`.split("\n")
21
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
- s.require_paths = ['lib']
23
-
24
- s.required_ruby_version = '>= 2.4'
25
-
26
- s.add_runtime_dependency 'ruby2_keywords'
27
-
28
- s.add_development_dependency 'redis', '~> 4.5.0'
29
- s.add_development_dependency 'rspec', '~> 3.0'
30
- s.add_development_dependency 'rspec-its', '~> 1.0'
31
- s.add_development_dependency 'timecop', '~> 0.9.1'
32
- end
data/spec/client_spec.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'client' do
4
- context '#reconnect' do
5
- it 'reconnects' do
6
- redis = MockRedis.new
7
- redis.reconnect.should == redis
8
- end
9
- end
10
-
11
- context '#connect' do
12
- it 'connects' do
13
- redis = MockRedis.new
14
- redis.connect.should == redis
15
- end
16
- end
17
-
18
- context '#disconnect!' do
19
- it 'responds to disconnect!' do
20
- expect(MockRedis.new).to respond_to(:disconnect!)
21
- end
22
- end
23
-
24
- context '#close' do
25
- it 'responds to close' do
26
- expect(MockRedis.new).to respond_to(:close)
27
- end
28
- end
29
-
30
- context '#with' do
31
- it 'supports with' do
32
- redis = MockRedis.new
33
- redis.with { |c| c.set('key', 'value') }.should == 'OK'
34
- end
35
- end
36
- end
data/spec/cloning_spec.rb DELETED
@@ -1,95 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'MockRedis#clone' do
4
- before do
5
- @mock = MockRedis.new
6
- end
7
-
8
- context 'the stored data' do
9
- before do
10
- @mock.set('foo', 'bar')
11
- @mock.hset('foohash', 'bar', 'baz')
12
- @mock.lpush('foolist', 'bar')
13
- @mock.sadd('fooset', 'bar')
14
- @mock.zadd('foozset', 1, 'bar')
15
-
16
- @clone = @mock.clone
17
- end
18
-
19
- it 'copies the stored data to the clone' do
20
- @clone.get('foo').should == 'bar'
21
- end
22
-
23
- it 'performs a deep copy (string values)' do
24
- @mock.del('foo')
25
- @clone.get('foo').should == 'bar'
26
- end
27
-
28
- it 'performs a deep copy (list values)' do
29
- @mock.lpop('foolist')
30
- @clone.lrange('foolist', 0, 1).should == ['bar']
31
- end
32
-
33
- it 'performs a deep copy (hash values)' do
34
- @mock.hset('foohash', 'bar', 'quux')
35
- @clone.hgetall('foohash').should == { 'bar' => 'baz' }
36
- end
37
-
38
- it 'performs a deep copy (set values)' do
39
- @mock.srem('fooset', 'bar')
40
- @clone.smembers('fooset').should == ['bar']
41
- end
42
-
43
- it 'performs a deep copy (zset values)' do
44
- @mock.zadd('foozset', 2, 'bar')
45
- @clone.zscore('foozset', 'bar').should == 1.0
46
- end
47
- end
48
-
49
- context 'expiration times' do
50
- before do
51
- @mock.set('foo', 1)
52
- @mock.expire('foo', 60_026)
53
-
54
- @clone = @mock.clone
55
- end
56
-
57
- it 'copies the expiration times' do
58
- @clone.ttl('foo').should > 0
59
- end
60
-
61
- it 'deep-copies the expiration times' do
62
- @mock.persist('foo')
63
- @clone.ttl('foo').should > 0
64
- end
65
-
66
- it 'deep-copies the expiration times' do
67
- @clone.persist('foo')
68
- @mock.ttl('foo').should > 0
69
- end
70
- end
71
-
72
- context 'transactional info' do
73
- before do
74
- @mock.multi
75
- @mock.incr('foo')
76
- @mock.incrby('foo', 2)
77
- @mock.incrby('foo', 4)
78
-
79
- @clone = @mock.clone
80
- end
81
-
82
- it 'makes sure the clone is in a transaction' do
83
- lambda do
84
- @clone.exec
85
- end.should_not raise_error
86
- end
87
-
88
- it 'deep-copies the queued commands' do
89
- @clone.incrby('foo', 8)
90
- @clone.exec.should == [1, 3, 7, 15]
91
-
92
- @mock.exec.should == [1, 3, 7]
93
- end
94
- end
95
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#append(key, value)' do
4
- before { @key = 'mock-redis-test:append' }
5
-
6
- it 'returns the new length of the string' do
7
- @redises.set(@key, 'porkchop')
8
- @redises.append(@key, 'sandwiches').should == 18
9
- end
10
-
11
- it 'appends value to the previously-stored value' do
12
- @redises.set(@key, 'porkchop')
13
- @redises.append(@key, 'sandwiches')
14
-
15
- @redises.get(@key).should == 'porkchopsandwiches'
16
- end
17
-
18
- it 'treats a missing key as an empty string' do
19
- @redises.append(@key, 'foo')
20
- @redises.get(@key).should == 'foo'
21
- end
22
-
23
- it_should_behave_like 'a string-only command'
24
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#auth(password) [mock only]' do
4
- it "just returns 'OK'" do
5
- @redises.mock.auth('foo').should == 'OK'
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#bgrewriteaof [mock only]' do
4
- it 'just returns a canned string' do
5
- @redises.mock.bgrewriteaof.should =~ /append/
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#bgsave [mock only]' do
4
- it 'just returns a canned string' do
5
- @redises.mock.bgsave.should =~ /saving/
6
- end
7
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#bitcount(key [, start, end ])' do
4
- before do
5
- @key = 'mock-redis-test:bitcount'
6
- @redises.set(@key, 'foobar')
7
- end
8
-
9
- it 'gets the number of set bits from the key' do
10
- @redises.bitcount(@key).should == 26
11
- end
12
-
13
- it 'gets the number of set bits from the key in an interval' do
14
- @redises.bitcount(@key, 0, 1000).should == 26
15
- @redises.bitcount(@key, 0, 0).should == 4
16
- @redises.bitcount(@key, 1, 1).should == 6
17
- @redises.bitcount(@key, 1, -2).should == 18
18
- end
19
-
20
- it 'treats nonexistent keys as empty strings' do
21
- @redises.bitcount('mock-redis-test:not-found').should == 0
22
- end
23
-
24
- it_should_behave_like 'a string-only command'
25
- end
@@ -1,169 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#bitfield(*args)' do
4
- before :each do
5
- @key = 'mock-redis-test:bitfield'
6
- @redises.set(@key, '')
7
-
8
- @redises.bitfield(@key, :set, 'i8', 0, 78)
9
- @redises.bitfield(@key, :set, 'i8', 8, 104)
10
- @redises.bitfield(@key, :set, 'i8', 16, -59)
11
- @redises.bitfield(@key, :set, 'u8', 24, 78)
12
- @redises.bitfield(@key, :set, 'u8', 32, 84)
13
- end
14
-
15
- context 'with a :get command' do
16
- it 'gets a signed 8 bit value' do
17
- @redises.bitfield(@key, :get, 'i8', 0).should == [78]
18
- @redises.bitfield(@key, :get, 'i8', 8).should == [104]
19
- @redises.bitfield(@key, :get, 'i8', 16).should == [-59]
20
- end
21
-
22
- it 'gets multiple values with multiple command args' do
23
- @redises.bitfield(@key, :get, 'i8', 0,
24
- :get, 'i8', 8,
25
- :get, 'i8', 16).should == [78, 104, -59]
26
- end
27
-
28
- it 'gets multiple values using positional offsets' do
29
- @redises.bitfield(@key, :get, 'i8', '#0',
30
- :get, 'i8', '#1',
31
- :get, 'i8', '#2').should == [78, 104, -59]
32
- end
33
-
34
- it 'shows an error with an invalid type' do
35
- expect do
36
- @redises.bitfield(@key, :get, 'u64', 0)
37
- end.to raise_error(Redis::CommandError)
38
- expect do
39
- @redises.bitfield(@key, :get, 'i128', 0)
40
- end.to raise_error(Redis::CommandError)
41
- end
42
-
43
- it 'does not throw an error with i64 type' do
44
- expect do
45
- @redises.bitfield(@key, :get, 'i64', 0)
46
- end.to_not raise_error
47
- end
48
- end
49
-
50
- context 'with a :set command' do
51
- it 'sets the bit values for an 8 bit signed integer' do
52
- @redises.bitfield(@key, :set, 'i8', 0, 63).should == [78]
53
- @redises.bitfield(@key, :set, 'i8', 8, -1).should == [104]
54
- @redises.bitfield(@key, :set, 'i8', 16, 123).should == [-59]
55
-
56
- @redises.bitfield(@key, :get, 'i8', 0,
57
- :get, 'i8', 8,
58
- :get, 'i8', 16).should == [63, -1, 123]
59
- end
60
-
61
- it 'sets multiple values with multiple command args' do
62
- @redises.bitfield(@key, :set, 'i8', 0, 63,
63
- :set, 'i8', 8, -1,
64
- :set, 'i8', 16, 123).should == [78, 104, -59]
65
-
66
- @redises.bitfield(@key, :get, 'i8', 0,
67
- :get, 'i8', 8,
68
- :get, 'i8', 16).should == [63, -1, 123]
69
- end
70
- end
71
-
72
- context 'with an :incrby command' do
73
- it 'returns the incremented by value for an 8 bit signed integer' do
74
- @redises.bitfield(@key, :incrby, 'i8', 0, 1).should == [79]
75
- @redises.bitfield(@key, :incrby, 'i8', 8, -1).should == [103]
76
- @redises.bitfield(@key, :incrby, 'i8', 16, 5).should == [-54]
77
- end
78
-
79
- context 'with an overflow of wrap (default)' do
80
- context 'for a signed integer' do
81
- it 'wraps the overflow to the minimum and increments from there' do
82
- @redises.bitfield(@key, :get, 'i8', 24).should == [78]
83
- @redises.bitfield(@key, :overflow, :wrap,
84
- :incrby, 'i8', 0, 200).should == [22]
85
- end
86
-
87
- it 'wraps the underflow to the maximum value and decrements from there' do
88
- @redises.bitfield(@key, :overflow, :wrap,
89
- :incrby, 'i8', 16, -200).should == [-3]
90
- end
91
- end
92
-
93
- context 'for an unsigned integer' do
94
- it 'wraps the overflow back to zero and increments from there' do
95
- @redises.bitfield(@key, :get, 'u8', 24).should == [78]
96
- @redises.bitfield(@key, :overflow, :wrap,
97
- :incrby, 'u8', 24, 233).should == [55]
98
- end
99
-
100
- it 'wraps the underflow to the maximum value and decrements from there' do
101
- @redises.bitfield(@key, :get, 'u8', 32).should == [84]
102
- @redises.bitfield(@key, :overflow, :wrap,
103
- :incrby, 'u8', 32, -233).should == [107]
104
- end
105
- end
106
- end
107
-
108
- context 'with an overflow of sat' do
109
- it 'sets the overflowed value to the maximum' do
110
- @redises.bitfield(@key, :overflow, :sat,
111
- :incrby, 'i8', 0, 256).should == [127]
112
- end
113
-
114
- it 'sets the underflowed value to the minimum' do
115
- @redises.bitfield(@key, :overflow, :sat,
116
- :incrby, 'i8', 16, -256).should == [-128]
117
- end
118
- end
119
-
120
- context 'with an overflow of fail' do
121
- it 'raises a redis error on an out of range value' do
122
- @redises.bitfield(@key, :overflow, :fail,
123
- :incrby, 'i8', 0, 256).should == [nil]
124
-
125
- @redises.bitfield(@key, :overflow, :fail,
126
- :incrby, 'i8', 16, -256).should == [nil]
127
- end
128
-
129
- it 'retains the original value after a failed increment' do
130
- @redises.bitfield(@key, :get, 'i8', 0).should == [78]
131
- @redises.bitfield(@key, :overflow, :fail,
132
- :incrby, 'i8', 0, 256).should == [nil]
133
- @redises.bitfield(@key, :get, 'i8', 0).should == [78]
134
- end
135
- end
136
-
137
- context 'with multiple overflow commands in one transaction' do
138
- it 'handles the overflow values correctly' do
139
- @redises.bitfield(@key, :overflow, :sat,
140
- :incrby, 'i8', 0, 256,
141
- :incrby, 'i8', 8, -256,
142
- :overflow, :wrap,
143
- :incrby, 'i8', 0, 200,
144
- :incrby, 'i8', 16, -200,
145
- :overflow, :fail,
146
- :incrby, 'i8', 0, 256,
147
- :incrby, 'i8', 16, -256).should == [127, -128, 71, -3, nil, nil]
148
- end
149
- end
150
-
151
- context 'with an unsupported overflow value' do
152
- it 'raises an error' do
153
- expect do
154
- @redises.bitfield(@key, :overflow, :foo,
155
- :incrby, 'i8', 0, 256)
156
- end.to raise_error(Redis::CommandError)
157
- end
158
- end
159
- end
160
-
161
- context 'with a mixed set of commands' do
162
- it 'returns the correct outputs' do
163
- @redises.bitfield(@key, :set, 'i8', 0, 38,
164
- :set, 'i8', 8, -99,
165
- :incrby, 'i8', 16, 1,
166
- :get, 'i8', 0).should == [78, 104, -58, 38]
167
- end
168
- end
169
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#blmove(source, destination, wherefrom, whereto, timeout)' do
4
- before do
5
- @list1 = 'mock-redis-test:blmove-list1'
6
- @list2 = 'mock-redis-test:blmove-list2'
7
-
8
- @redises.lpush(@list1, 'b')
9
- @redises.lpush(@list1, 'a')
10
-
11
- @redises.lpush(@list2, 'y')
12
- @redises.lpush(@list2, 'x')
13
- end
14
-
15
- it 'returns the value moved' do
16
- @redises.blmove(@list1, @list2, 'left', 'right').should == 'a'
17
- end
18
-
19
- it 'takes the first element of source and appends it to destination' do
20
- @redises.blmove(@list1, @list2, 'left', 'right')
21
-
22
- @redises.lrange(@list1, 0, -1).should == %w[b]
23
- @redises.lrange(@list2, 0, -1).should == %w[x y a]
24
- end
25
-
26
- it 'raises an error on negative timeout' do
27
- lambda do
28
- @redises.blmove(@list1, @list2, 'left', 'right', :timeout => -1)
29
- end.should raise_error(Redis::CommandError)
30
- end
31
-
32
- let(:default_error) { RedisMultiplexer::MismatchedResponse }
33
- it_should_behave_like 'a list-only command'
34
-
35
- context '[mock only]' do
36
- it 'ignores positive timeouts and returns nil' do
37
- @redises.mock.blmove('mock-redis-test:not-here', @list1, 'left', 'right', :timeout => 1).
38
- should be_nil
39
- end
40
-
41
- it 'ignores positive legacy timeouts and returns nil' do
42
- @redises.mock.blmove('mock-redis-test:not-here', @list1, 'left', 'right', 1).
43
- should be_nil
44
- end
45
-
46
- it 'raises WouldBlock on zero timeout (no blocking in the mock)' do
47
- lambda do
48
- @redises.mock.blmove('mock-redis-test:not-here', @list1, 'left', 'right', :timeout => 0)
49
- end.should raise_error(MockRedis::WouldBlock)
50
- end
51
- end
52
- end