mock_redis 0.36.0 → 0.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/lib/mock_redis/database.rb +1 -1
- data/lib/mock_redis/hash_methods.rb +1 -1
- data/lib/mock_redis/list_methods.rb +7 -2
- data/lib/mock_redis/multi_db_wrapper.rb +1 -1
- data/lib/mock_redis/pipelined_wrapper.rb +12 -14
- data/lib/mock_redis/set_methods.rb +6 -1
- data/lib/mock_redis/stream.rb +3 -3
- data/lib/mock_redis/string_methods.rb +3 -3
- data/lib/mock_redis/transaction_wrapper.rb +5 -7
- data/lib/mock_redis/utility_methods.rb +4 -2
- data/lib/mock_redis/version.rb +1 -1
- data/lib/mock_redis/zset.rb +4 -2
- data/lib/mock_redis/zset_methods.rb +3 -3
- data/lib/mock_redis.rb +1 -2
- metadata +19 -360
- data/.github/workflows/lint.yml +0 -31
- data/.github/workflows/tests.yml +0 -63
- data/.gitignore +0 -5
- data/.mailmap +0 -2
- data/.overcommit.yml +0 -21
- data/.rspec +0 -1
- data/.rubocop.yml +0 -148
- data/.rubocop_todo.yml +0 -35
- data/.simplecov +0 -4
- data/Gemfile +0 -13
- data/Rakefile +0 -2
- data/mock_redis.gemspec +0 -32
- data/spec/client_spec.rb +0 -36
- data/spec/cloning_spec.rb +0 -95
- data/spec/commands/append_spec.rb +0 -24
- data/spec/commands/auth_spec.rb +0 -7
- data/spec/commands/bgrewriteaof_spec.rb +0 -7
- data/spec/commands/bgsave_spec.rb +0 -7
- data/spec/commands/bitcount_spec.rb +0 -25
- data/spec/commands/bitfield_spec.rb +0 -169
- data/spec/commands/blmove_spec.rb +0 -52
- data/spec/commands/blpop_spec.rb +0 -53
- data/spec/commands/brpop_spec.rb +0 -59
- data/spec/commands/brpoplpush_spec.rb +0 -52
- data/spec/commands/connected_spec.rb +0 -7
- data/spec/commands/connection_spec.rb +0 -15
- data/spec/commands/dbsize_spec.rb +0 -18
- data/spec/commands/decr_spec.rb +0 -34
- data/spec/commands/decrby_spec.rb +0 -34
- data/spec/commands/del_spec.rb +0 -52
- data/spec/commands/disconnect_spec.rb +0 -7
- data/spec/commands/dump_spec.rb +0 -19
- data/spec/commands/echo_spec.rb +0 -11
- data/spec/commands/eval_spec.rb +0 -7
- data/spec/commands/evalsha_spec.rb +0 -10
- data/spec/commands/exists_spec.rb +0 -43
- data/spec/commands/expire_spec.rb +0 -111
- data/spec/commands/expireat_spec.rb +0 -47
- data/spec/commands/flushall_spec.rb +0 -38
- data/spec/commands/flushdb_spec.rb +0 -38
- data/spec/commands/future_spec.rb +0 -30
- data/spec/commands/geoadd_spec.rb +0 -58
- data/spec/commands/geodist_spec.rb +0 -118
- data/spec/commands/geohash_spec.rb +0 -52
- data/spec/commands/geopos_spec.rb +0 -55
- data/spec/commands/get_spec.rb +0 -31
- data/spec/commands/getbit_spec.rb +0 -34
- data/spec/commands/getdel.rb +0 -24
- data/spec/commands/getrange_spec.rb +0 -22
- data/spec/commands/getset_spec.rb +0 -23
- data/spec/commands/hdel_spec.rb +0 -77
- data/spec/commands/hexists_spec.rb +0 -27
- data/spec/commands/hget_spec.rb +0 -28
- data/spec/commands/hgetall_spec.rb +0 -32
- data/spec/commands/hincrby_spec.rb +0 -58
- data/spec/commands/hincrbyfloat_spec.rb +0 -58
- data/spec/commands/hkeys_spec.rb +0 -19
- data/spec/commands/hlen_spec.rb +0 -19
- data/spec/commands/hmget_spec.rb +0 -46
- data/spec/commands/hmset_spec.rb +0 -69
- data/spec/commands/hscan_each_spec.rb +0 -48
- data/spec/commands/hscan_spec.rb +0 -27
- data/spec/commands/hset_spec.rb +0 -42
- data/spec/commands/hsetnx_spec.rb +0 -44
- data/spec/commands/hvals_spec.rb +0 -19
- data/spec/commands/incr_spec.rb +0 -34
- data/spec/commands/incrby_spec.rb +0 -44
- data/spec/commands/incrbyfloat_spec.rb +0 -44
- data/spec/commands/info_spec.rb +0 -62
- data/spec/commands/keys_spec.rb +0 -139
- data/spec/commands/lastsave_spec.rb +0 -8
- data/spec/commands/lindex_spec.rb +0 -49
- data/spec/commands/linsert_spec.rb +0 -68
- data/spec/commands/llen_spec.rb +0 -16
- data/spec/commands/lmove_spec.rb +0 -72
- data/spec/commands/lpop_spec.rb +0 -35
- data/spec/commands/lpush_spec.rb +0 -43
- data/spec/commands/lpushx_spec.rb +0 -46
- data/spec/commands/lrange_spec.rb +0 -51
- data/spec/commands/lrem_spec.rb +0 -80
- data/spec/commands/lset_spec.rb +0 -43
- data/spec/commands/ltrim_spec.rb +0 -45
- data/spec/commands/mapped_hmget_spec.rb +0 -29
- data/spec/commands/mapped_hmset_spec.rb +0 -47
- data/spec/commands/mapped_mget_spec.rb +0 -22
- data/spec/commands/mapped_mset_spec.rb +0 -19
- data/spec/commands/mapped_msetnx_spec.rb +0 -26
- data/spec/commands/mget_spec.rb +0 -65
- data/spec/commands/move_spec.rb +0 -147
- data/spec/commands/mset_spec.rb +0 -43
- data/spec/commands/msetnx_spec.rb +0 -40
- data/spec/commands/persist_spec.rb +0 -48
- data/spec/commands/pexpire_spec.rb +0 -86
- data/spec/commands/pexpireat_spec.rb +0 -48
- data/spec/commands/ping_spec.rb +0 -11
- data/spec/commands/pipelined_spec.rb +0 -114
- data/spec/commands/psetex_spec.rb +0 -44
- data/spec/commands/pttl_spec.rb +0 -41
- data/spec/commands/quit_spec.rb +0 -7
- data/spec/commands/randomkey_spec.rb +0 -20
- data/spec/commands/rename_spec.rb +0 -42
- data/spec/commands/renamenx_spec.rb +0 -41
- data/spec/commands/restore_spec.rb +0 -47
- data/spec/commands/rpop_spec.rb +0 -35
- data/spec/commands/rpoplpush_spec.rb +0 -50
- data/spec/commands/rpush_spec.rb +0 -43
- data/spec/commands/rpushx_spec.rb +0 -46
- data/spec/commands/sadd_spec.rb +0 -45
- data/spec/commands/save_spec.rb +0 -7
- data/spec/commands/scan_each_spec.rb +0 -39
- data/spec/commands/scan_spec.rb +0 -64
- data/spec/commands/scard_spec.rb +0 -18
- data/spec/commands/script_spec.rb +0 -9
- data/spec/commands/sdiff_spec.rb +0 -47
- data/spec/commands/sdiffstore_spec.rb +0 -58
- data/spec/commands/select_spec.rb +0 -61
- data/spec/commands/set_spec.rb +0 -134
- data/spec/commands/setbit_spec.rb +0 -55
- data/spec/commands/setex_spec.rb +0 -38
- data/spec/commands/setnx_spec.rb +0 -25
- data/spec/commands/setrange_spec.rb +0 -30
- data/spec/commands/sinter_spec.rb +0 -39
- data/spec/commands/sinterstore_spec.rb +0 -53
- data/spec/commands/sismember_spec.rb +0 -29
- data/spec/commands/smembers_spec.rb +0 -28
- data/spec/commands/smismember_spec.rb +0 -34
- data/spec/commands/smove_spec.rb +0 -41
- data/spec/commands/sort_list_spec.rb +0 -21
- data/spec/commands/sort_set_spec.rb +0 -21
- data/spec/commands/sort_zset_spec.rb +0 -21
- data/spec/commands/spop_spec.rb +0 -40
- data/spec/commands/srandmember_spec.rb +0 -49
- data/spec/commands/srem_spec.rb +0 -45
- data/spec/commands/sscan_each_spec.rb +0 -48
- data/spec/commands/sscan_spec.rb +0 -39
- data/spec/commands/strlen_spec.rb +0 -18
- data/spec/commands/sunion_spec.rb +0 -42
- data/spec/commands/sunionstore_spec.rb +0 -59
- data/spec/commands/ttl_spec.rb +0 -40
- data/spec/commands/type_spec.rb +0 -36
- data/spec/commands/unwatch_spec.rb +0 -7
- data/spec/commands/watch_spec.rb +0 -21
- data/spec/commands/xadd_spec.rb +0 -122
- data/spec/commands/xlen_spec.rb +0 -22
- data/spec/commands/xrange_spec.rb +0 -164
- data/spec/commands/xread_spec.rb +0 -66
- data/spec/commands/xrevrange_spec.rb +0 -130
- data/spec/commands/xtrim_spec.rb +0 -36
- data/spec/commands/zadd_spec.rb +0 -129
- data/spec/commands/zcard_spec.rb +0 -19
- data/spec/commands/zcount_spec.rb +0 -39
- data/spec/commands/zincrby_spec.rb +0 -31
- data/spec/commands/zinterstore_spec.rb +0 -130
- data/spec/commands/zpopmax_spec.rb +0 -60
- data/spec/commands/zpopmin_spec.rb +0 -60
- data/spec/commands/zrange_spec.rb +0 -80
- data/spec/commands/zrangebyscore_spec.rb +0 -83
- data/spec/commands/zrank_spec.rb +0 -29
- data/spec/commands/zrem_spec.rb +0 -50
- data/spec/commands/zremrangebyrank_spec.rb +0 -27
- data/spec/commands/zremrangebyscore_spec.rb +0 -35
- data/spec/commands/zrevrange_spec.rb +0 -56
- data/spec/commands/zrevrangebyscore_spec.rb +0 -58
- data/spec/commands/zrevrank_spec.rb +0 -29
- data/spec/commands/zscan_each_spec.rb +0 -48
- data/spec/commands/zscan_spec.rb +0 -26
- data/spec/commands/zscore_spec.rb +0 -22
- data/spec/commands/zunionstore_spec.rb +0 -137
- data/spec/mock_redis_spec.rb +0 -93
- data/spec/spec_helper.rb +0 -74
- data/spec/support/redis_multiplexer.rb +0 -123
- data/spec/support/shared_examples/does_not_cleanup_empty_strings.rb +0 -14
- data/spec/support/shared_examples/only_operates_on_hashes.rb +0 -15
- data/spec/support/shared_examples/only_operates_on_lists.rb +0 -15
- data/spec/support/shared_examples/only_operates_on_sets.rb +0 -15
- data/spec/support/shared_examples/only_operates_on_strings.rb +0 -13
- data/spec/support/shared_examples/only_operates_on_zsets.rb +0 -59
- data/spec/support/shared_examples/sorts_enumerables.rb +0 -56
- data/spec/transactions_spec.rb +0 -163
@@ -1,15 +0,0 @@
|
|
1
|
-
shared_examples_for 'a hash-only command' do
|
2
|
-
it 'raises an error for non-hash values' do |example|
|
3
|
-
key = 'mock-redis-test:hash-only'
|
4
|
-
|
5
|
-
method = method_from_description(example)
|
6
|
-
args = args_for_method(method).unshift(key)
|
7
|
-
|
8
|
-
@redises.set(key, 1)
|
9
|
-
lambda do
|
10
|
-
@redises.send(method, *args)
|
11
|
-
end.should raise_error(RuntimeError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'does not remove empty strings on error'
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
shared_examples_for 'a list-only command' do
|
2
|
-
it 'raises an error for non-list values' do |example|
|
3
|
-
key = 'mock-redis-test:list-only'
|
4
|
-
|
5
|
-
method = method_from_description(example)
|
6
|
-
args = args_for_method(method).unshift(key)
|
7
|
-
|
8
|
-
@redises.set(key, 1)
|
9
|
-
lambda do
|
10
|
-
@redises.send(method, *args)
|
11
|
-
end.should raise_error(defined?(default_error) ? default_error : RuntimeError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'does not remove empty strings on error'
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
shared_examples_for 'a set-only command' do
|
2
|
-
it 'raises an error for non-set values' do |example|
|
3
|
-
key = 'mock-redis-test:set-only'
|
4
|
-
|
5
|
-
method = method_from_description(example)
|
6
|
-
args = args_for_method(method).unshift(key)
|
7
|
-
|
8
|
-
@redises.set(key, 1)
|
9
|
-
lambda do
|
10
|
-
@redises.send(method, *args)
|
11
|
-
end.should raise_error(RuntimeError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'does not remove empty strings on error'
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
shared_examples_for 'a string-only command' do
|
2
|
-
it 'raises an error for non-string values' do |example|
|
3
|
-
key = 'mock-redis-test:string-only-command'
|
4
|
-
|
5
|
-
method = method_from_description(example)
|
6
|
-
args = args_for_method(method).unshift(key)
|
7
|
-
|
8
|
-
@redises.lpush(key, 1)
|
9
|
-
lambda do
|
10
|
-
@redises.send(method, *args)
|
11
|
-
end.should raise_error(RuntimeError)
|
12
|
-
end
|
13
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
shared_examples_for 'a zset-only command' do
|
2
|
-
it 'raises an error for non-zset values' do |example|
|
3
|
-
key = 'mock-redis-test:zset-only'
|
4
|
-
|
5
|
-
method = method_from_description(example)
|
6
|
-
args = args_for_method(method).unshift(key)
|
7
|
-
|
8
|
-
@redises.set(key, 1)
|
9
|
-
lambda do
|
10
|
-
@redises.send(method, *args)
|
11
|
-
end.should raise_error(RuntimeError)
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'does not remove empty strings on error'
|
15
|
-
end
|
16
|
-
|
17
|
-
shared_examples_for 'arg 1 is a score' do
|
18
|
-
before { @_arg_index = 1 }
|
19
|
-
it_should_behave_like 'arg N is a score'
|
20
|
-
end
|
21
|
-
|
22
|
-
shared_examples_for 'arg 2 is a score' do
|
23
|
-
before { @_arg_index = 2 }
|
24
|
-
it_should_behave_like 'arg N is a score'
|
25
|
-
end
|
26
|
-
|
27
|
-
shared_examples_for 'arg N is a score' do
|
28
|
-
before do |example|
|
29
|
-
key = 'mock-redis-test:zset-only'
|
30
|
-
|
31
|
-
@method = method_from_description(example)
|
32
|
-
@args = args_for_method(@method).unshift(key)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'is okay with positive ints' do
|
36
|
-
@args[@_arg_index] = 1
|
37
|
-
lambda { @redises.send(@method, *@args) }.should_not raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'is okay with negative ints' do
|
41
|
-
@args[@_arg_index] = -1
|
42
|
-
lambda { @redises.send(@method, *@args) }.should_not raise_error
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'is okay with positive floats' do
|
46
|
-
@args[@_arg_index] = 1.5
|
47
|
-
lambda { @redises.send(@method, *@args) }.should_not raise_error
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'is okay with negative floats' do
|
51
|
-
@args[@_arg_index] = -1.5
|
52
|
-
lambda { @redises.send(@method, *@args) }.should_not raise_error
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'rejects non-numbers' do
|
56
|
-
@args[@_arg_index] = 'foo'
|
57
|
-
lambda { @redises.send(@method, *@args) }.should raise_error(RuntimeError)
|
58
|
-
end
|
59
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
shared_examples_for 'a sortable' do
|
2
|
-
it 'returns empty array on nil' do
|
3
|
-
@redises.sort(nil).should == []
|
4
|
-
end
|
5
|
-
|
6
|
-
context 'ordering' do
|
7
|
-
it 'orders ascending by default' do
|
8
|
-
@redises.sort(@key).should == %w[1 2]
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'orders by descending when specified' do
|
12
|
-
@redises.sort(@key, :order => 'DESC').should == %w[2 1]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'projections' do
|
17
|
-
it 'projects element when :get is "#"' do
|
18
|
-
@redises.sort(@key, :get => '#').should == %w[1 2]
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'projects through a key pattern' do
|
22
|
-
@redises.sort(@key, :get => 'mock-redis-test:values_*').should == %w[a b]
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'projects through a key pattern and reflects element' do
|
26
|
-
@redises.sort(@key, :get => ['#', 'mock-redis-test:values_*']).should == [%w[1 a], %w[2 b]]
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'projects through a hash key pattern' do
|
30
|
-
@redises.sort(@key, :get => 'mock-redis-test:hash_*->key').should == %w[x y]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'weights' do
|
35
|
-
it 'weights by projecting through a key pattern' do
|
36
|
-
@redises.sort(@key, :by => 'mock-redis-test:weight_*').should == %w[2 1]
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'weights by projecting through a key pattern and a specific order' do
|
40
|
-
@redises.sort(@key, :order => 'DESC', :by => 'mock-redis-test:weight_*').should == %w[1 2]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'limit' do
|
45
|
-
it 'only returns requested window in the enumerable' do
|
46
|
-
@redises.sort(@key, :limit => [0, 1]).should == ['1']
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'store' do
|
51
|
-
it 'stores into another key' do
|
52
|
-
@redises.sort(@key, :store => 'mock-redis-test:some_bucket').should == 2
|
53
|
-
@redises.lrange('mock-redis-test:some_bucket', 0, -1).should == %w[1 2]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/spec/transactions_spec.rb
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'transactions (multi/exec/discard)' do
|
4
|
-
before(:each) do
|
5
|
-
@redises.discard rescue nil
|
6
|
-
end
|
7
|
-
|
8
|
-
context '#multi' do
|
9
|
-
it "responds with 'OK'" do
|
10
|
-
@redises.multi.should == 'OK'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'does not permit nesting' do
|
14
|
-
@redises.multi
|
15
|
-
lambda do
|
16
|
-
@redises.multi
|
17
|
-
end.should raise_error(Redis::CommandError, 'ERR MULTI calls can not be nested')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'cleans state of transaction wrapper if exception occurs during transaction' do
|
21
|
-
lambda do
|
22
|
-
@redises.mock.multi do |_r|
|
23
|
-
raise "i'm a command that fails"
|
24
|
-
end
|
25
|
-
end.should raise_error(RuntimeError)
|
26
|
-
|
27
|
-
# before the fix this used to raised a #<RuntimeError: ERR MULTI calls can not be nested>
|
28
|
-
lambda do
|
29
|
-
@redises.mock.multi do |r|
|
30
|
-
# do stuff that succeed
|
31
|
-
r.set(nil, 'string')
|
32
|
-
end
|
33
|
-
end.should_not raise_error
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context '#blocks' do
|
38
|
-
it 'implicitly runs exec when finished' do
|
39
|
-
@redises.set('counter', 5)
|
40
|
-
@redises.multi do |r|
|
41
|
-
r.set('test', 1)
|
42
|
-
r.incr('counter')
|
43
|
-
end
|
44
|
-
@redises.get('counter').should eq '6'
|
45
|
-
@redises.get('test').should eq '1'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'permits nesting via blocks' do
|
49
|
-
# Have to use only the mock here. redis-rb has a bug in it where
|
50
|
-
# nested #multi calls raise NoMethodError because it gets a nil
|
51
|
-
# where it's not expecting one.
|
52
|
-
@redises.mock.multi do |r|
|
53
|
-
lambda do
|
54
|
-
r.multi {}
|
55
|
-
end.should_not raise_error
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'allows pipelined calls within multi blocks' do
|
60
|
-
@redises.set('counter', 5)
|
61
|
-
@redises.multi do |r|
|
62
|
-
r.pipelined do |pr|
|
63
|
-
pr.set('test', 1)
|
64
|
-
pr.incr('counter')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
@redises.get('counter').should eq '6'
|
68
|
-
@redises.get('test').should eq '1'
|
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
|
86
|
-
end
|
87
|
-
|
88
|
-
context '#discard' do
|
89
|
-
it "responds with 'OK' after #multi" do
|
90
|
-
@redises.multi
|
91
|
-
@redises.discard.should eq 'OK'
|
92
|
-
end
|
93
|
-
|
94
|
-
it "can't be run outside of #multi/#exec" do
|
95
|
-
lambda do
|
96
|
-
@redises.discard
|
97
|
-
end.should raise_error(Redis::CommandError)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context '#exec' do
|
102
|
-
it 'raises an error outside of #multi' do
|
103
|
-
lambda do
|
104
|
-
@redises.exec.should raise_error
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'saving up commands for later' do
|
110
|
-
before(:each) do
|
111
|
-
@redises.multi
|
112
|
-
@string = 'mock-redis-test:string'
|
113
|
-
@list = 'mock-redis-test:list'
|
114
|
-
end
|
115
|
-
|
116
|
-
it "makes commands respond with 'QUEUED'" do
|
117
|
-
@redises.set(@string, 'string').should eq 'QUEUED'
|
118
|
-
@redises.lpush(@list, 'list').should eq 'QUEUED'
|
119
|
-
end
|
120
|
-
|
121
|
-
it "gives you the commands' responses when you call #exec" do
|
122
|
-
@redises.set(@string, 'string')
|
123
|
-
@redises.lpush(@list, 'list')
|
124
|
-
@redises.lpush(@list, 'list')
|
125
|
-
|
126
|
-
@redises.exec.should eq ['OK', 1, 2]
|
127
|
-
end
|
128
|
-
|
129
|
-
it "does not raise exceptions, but rather puts them in #exec's response" do
|
130
|
-
@redises.set(@string, 'string')
|
131
|
-
@redises.lpush(@string, 'oops!')
|
132
|
-
@redises.lpush(@list, 'list')
|
133
|
-
|
134
|
-
responses = @redises.exec
|
135
|
-
responses[0].should eq 'OK'
|
136
|
-
responses[1].should be_a(Redis::CommandError)
|
137
|
-
responses[2].should eq 1
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'saving commands with multi block' do
|
142
|
-
before(:each) do
|
143
|
-
@string = 'mock-redis-test:string'
|
144
|
-
@list = 'mock-redis-test:list'
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'commands return response after exec is called' do
|
148
|
-
set_response = nil
|
149
|
-
lpush_response = nil
|
150
|
-
second_lpush_response = nil
|
151
|
-
|
152
|
-
@redises.multi do |mult|
|
153
|
-
set_response = mult.set(@string, 'string')
|
154
|
-
lpush_response = mult.lpush(@list, 'list')
|
155
|
-
second_lpush_response = mult.lpush(@list, 'list')
|
156
|
-
end
|
157
|
-
|
158
|
-
set_response.value.should eq 'OK'
|
159
|
-
lpush_response.value.should eq 1
|
160
|
-
second_lpush_response.value.should eq 2
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|