Skip to content
This repository
Newer
Older
100644 66 lines (53 sloc) 1.421 kb
848b2606 »
2010-06-27 em-redis support, take one
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
8 connection.connected.should be_true
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
26 it "should incr/decr key synchronously" do
27 EventMachine.synchrony do
28 redis = EM::Protocols::Redis.connect
29 redis.delete('key')
30
31 redis.incr('key')
32 redis.get('key').to_i.should == 1
33
34 redis.decr('key')
35 redis.get('key').to_i.should == 0
36
37 EM.stop
38 end
39 end
40
41 it "should execute async commands" do
42 EventMachine.synchrony do
43 redis = EM::Protocols::Redis.connect
44 redis.set('a', 'foobar')
45 redis.aget('a') do |response|
46 response.should == 'foobar'
47 EM.stop
48 end
49 end
50 end
51
52 it "should execute async set add" do
53 EventMachine.synchrony do
54 redis = EM::Protocols::Redis.connect
55
56 redis.asadd('test', 'hai') do
57 redis.asadd('test', 'bai') do
58 redis.aset_count('test') do |resp|
59 resp.to_i.should == 2
60 EM.stop
61 end
62 end
63 end
64 end
65 end
66 end
Something went wrong with that request. Please try again.