Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 106 lines (84 sloc) 2.387 kB
848b260 @igrigorik em-redis support, take one
authored
1 require "spec/helper/all"
2
3 describe EM::Protocols::Redis do
4
5 it "should yield until connection is ready" do
6 EventMachine.synchrony do
7 connection = EM::Protocols::Redis.connect
2364b44 @dgutov be_true works differently in RSpec 3
dgutov authored
8 connection.connected.should eq(true)
848b260 @igrigorik em-redis support, take one
authored
9
10 EventMachine.stop
11 end
12 end
13
14 it "should get/set records synchronously" do
15 EventMachine.synchrony do
16 redis = EM::Protocols::Redis.connect
17
18 redis.set('a', 'foo')
19 redis.get('a').should == 'foo'
20 redis.get('c').should == nil
21
22 EM.stop
23 end
24 end
25
79b2f5d @bts fix wrapper for em-redis' mapped_mget
bts authored
26 it "should mapped_mget synchronously" do
27 EventMachine.synchrony do
28 redis = EM::Protocols::Redis.connect
29
30 redis.set('mmget1', 'value1')
31 redis.set('mmget3', 'value3')
32 redis.mapped_mget('mmget1', 'mmget2', 'mmget3').should ==
7e9a32d @igrigorik fix async auth / add in em-redis. closes #22
authored
33 { 'mmget1' => 'value1', 'mmget3' => 'value3' }
79b2f5d @bts fix wrapper for em-redis' mapped_mget
bts authored
34
35 EM.stop
36 end
37 end
38
848b260 @igrigorik em-redis support, take one
authored
39 it "should incr/decr key synchronously" do
40 EventMachine.synchrony do
41 redis = EM::Protocols::Redis.connect
42 redis.delete('key')
43
44 redis.incr('key')
45 redis.get('key').to_i.should == 1
46
47 redis.decr('key')
48 redis.get('key').to_i.should == 0
49
50 EM.stop
51 end
52 end
53
54 it "should execute async commands" do
55 EventMachine.synchrony do
56 redis = EM::Protocols::Redis.connect
57 redis.set('a', 'foobar')
58 redis.aget('a') do |response|
59 response.should == 'foobar'
60 EM.stop
61 end
62 end
63 end
64
65 it "should execute async set add" do
66 EventMachine.synchrony do
67 redis = EM::Protocols::Redis.connect
68
69 redis.asadd('test', 'hai') do
70 redis.asadd('test', 'bai') do
71 redis.aset_count('test') do |resp|
72 resp.to_i.should == 2
73 EM.stop
74 end
75 end
76 end
77 end
78 end
79b2f5d @bts fix wrapper for em-redis' mapped_mget
bts authored
79
80 it "should execute async mapped_mget" do
7e9a32d @igrigorik fix async auth / add in em-redis. closes #22
authored
81 EventMachine.synchrony do
79b2f5d @bts fix wrapper for em-redis' mapped_mget
bts authored
82 redis = EM::Protocols::Redis.connect
83
84 redis.aset('some_key', 'some_value') do
85 redis.amapped_mget('some_key', 'some_other_key') do |values|
86 values.should == { 'some_key' => 'some_value' }
87 EM.stop
88 end
89 end
90 end
91 end
7e9a32d @igrigorik fix async auth / add in em-redis. closes #22
authored
92
f1c378c @dgutov Skip certain specs when running on CI
dgutov authored
93 it "should execute sync add and auth", ci_skip: true do
7e9a32d @igrigorik fix async auth / add in em-redis. closes #22
authored
94 EventMachine.synchrony do
95 redis = EM::Protocols::Redis.connect
96 redis.auth('abc')
97
98 redis.delete('key')
99 redis.add('key', 'value')
100 redis.scard('key').should == 1
101
102 EM.stop
103 end
104 end
2364b44 @dgutov be_true works differently in RSpec 3
dgutov authored
105 end
Something went wrong with that request. Please try again.