Sha256: 04d480c1da25bb068b3f80e2a19bfd500ac93b2be8dc8a668943f5bbef9bbbf6
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' describe Mongo::Lock do describe '#acquired?' do let(:lock) { Mongo::Lock.new 'my_lock', owner: 'spence', timeout_in: 0.01, frequency: 0.01 } context "when the lock has been acquired" do it "returns true" do lock.acquire expect(lock.acquired?).to be_true end end context "when the lock hasn't been acquired" do it "returns false" do collection.insert key: 'my_lock', owner: 'tobie', expires_at: 1.minute.from_now lock.acquire expect(lock.acquired?).to be_false end end context "when the lock was acquired but has since expired" do it "returns false" do collection.insert key: 'my_lock', owner: 'spence', expires_at: 0.1.seconds.from_now lock.acquire sleep 0.2 expect(lock.acquired?).to be_false end end context "when the lock was acquired but has since been released" do it "returns false" do collection.insert key: 'my_lock', owner: 'tobie', expires_at: 1.minute.ago lock.acquire lock.release expect(lock.acquired?).to be_false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo-lock-1.1.0 | spec/acquired_spec.rb |