Sha256: d51846e7881a7c277579da0862f2dcb27266323cadddd061f9176ee7c22cf7b2

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

require 'spec_helper'

describe 'try_acquire_lock' do
  
  it "acquires lock when the lock does not exist" do
    
    @redis.send(:try_acquire_lock, "test").should == true
    
  end
  
  it "does not acquire lock when the lock is alive" do
    
    @redis.send(:try_acquire_lock, "test").should == true
    @redis.send(:try_acquire_lock, "test").should == false
    
  end
  
  it "acquires lock when the lock is expired" do
    
    @redis.send(:try_acquire_lock, "test", 0.1).should == true
    
    sleep(1)
    @redis.send(:try_acquire_lock, "test").should == true
    
  end
  
  it "does not acquire lock when the lock is expired but somebody else already successfully acquire the same lock" do
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_redis_lock-0.1.2 spec/lib/try_acquire_lock_spec.rb
ruby_redis_lock-0.1.1 spec/lib/try_acquire_lock_spec.rb