Sha256: e8f62757969b36483157836816005b7b2739f642ba68a8c6032ecb47887e31ef

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 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

1 entries across 1 versions & 1 rubygems

Version Path
ruby_redis_lock-0.1.0 spec/try_acquire_lock_spec.rb