diff --git a/spec/redis/connection/celluloid_spec.rb b/spec/redis/connection/celluloid_spec.rb index 7aa3ada..d26dc5e 100644 --- a/spec/redis/connection/celluloid_spec.rb +++ b/spec/redis/connection/celluloid_spec.rb @@ -21,4 +21,40 @@ expect { redis.shutdown }.not_to raise_error end end + + describe "using inside Celluloid::IO" do + before do + class Incrementor + include Celluloid::IO + + def initialize + @redis = Redis.new(:driver => :celluloid) + end + + def increment! + sleep(rand / 10) + @redis.incr 'rabbits' + rescue + STDERR.puts "I cannot increment rabbits because of #{$!.inspect}!" + raise RuntimeError + end + end + end + + let(:actor) { + Incrementor.new + } + let(:count) { 1000 } + + it "just survives" do + redis = Redis.new + redis.set 'rabbits', 0 + + count.times do + actor.async.increment! rescue nil + end + sleep 1 + expect(redis.get 'rabbits').to eq(count.to_s) + end + end end