spec/redis_mutex_spec.rb in redis-mutex-2.1.1 vs spec/redis_mutex_spec.rb in redis-mutex-3.0.0
- old
+ new
@@ -1,19 +1,9 @@
require 'spec_helper'
SHORT_MUTEX_OPTIONS = { :block => 0.1, :sleep => 0.02 }
-class C
- include Redis::Mutex::Macro
- auto_mutex :run_singularly, :block => 0, :after_failure => lambda {|id| return "failure: #{id}" }
-
- def run_singularly(id)
- sleep 0.1
- return "success: #{id}"
- end
-end
-
describe Redis::Mutex do
before do
Redis::Classy.flushdb
end
@@ -156,21 +146,9 @@
Redis::Mutex.set(:present, Time.now.to_f)
Redis::Mutex.set(:future, Time.now.to_f + 60)
Redis::Mutex.keys.size.should == 3
Redis::Mutex.sweep.should == 2
Redis::Mutex.keys.size.should == 1
- end
-
- describe Redis::Mutex::Macro do
- it 'adds auto_mutex' do
- t1 = Thread.new { C.new.run_singularly(1).should == "success: 1" }
- # In most cases t1 wins, but make sure to give it a head start,
- # not exceeding the sleep inside the method.
- sleep 0.01
- t2 = Thread.new { C.new.run_singularly(2).should == "failure: 2" }
- t1.join
- t2.join
- end
end
describe 'stress test' do
LOOP_NUM = 1000