spec/available_spec.rb in mongo-lock-1.1.0 vs spec/available_spec.rb in mongo-lock-1.1.1
- old
+ new
@@ -2,24 +2,24 @@
describe Mongo::Lock do
describe '.available?' do
- it "creates and returns a new Mongo::Lock instance" do
- expect(Mongo::Lock.available? 'my_lock').to be_a Mongo::Lock
+ it "creates a new Mongo::Lock instance and returns whether it is available" do
+ expect(Mongo::Lock.available? 'my_lock').to be_true
end
it "calls #available?" do
expect_any_instance_of(Mongo::Lock).to receive(:available?)
Mongo::Lock.available? 'my_lock'
end
context "when options are provided" do
it "passes them to the new lock" do
- lock = Mongo::Lock.available?('my_lock', { owner: 'spence' })
- expect(lock.configuration.owner).to eql 'spence'
+ Mongo::Lock.acquire 'my_lock', { owner: 'spence' }
+ expect(Mongo::Lock.available?('my_lock', { owner: 'spence' })).to be_true
end
end
end
@@ -37,28 +37,28 @@
end
context "when the lock is expired" do
it "returns true" do
- collection.insert key: 'my_lock', owner: 'tobie', expires_at: 1.minute.ago
+ my_collection.insert key: 'my_lock', owner: 'tobie', expires_at: 1.minute.ago
expect(lock.available?).to be_true
end
end
context "when the lock is already acquired but by this owner" do
it "returns true" do
- collection.insert key: 'my_lock', owner: 'spence', expires_at: 1.minute.from_now
+ my_collection.insert key: 'my_lock', owner: 'spence', expires_at: 1.minute.from_now
expect(lock.available?).to be_true
end
end
context "when the lock is already acquired" do
it "returns false" do
- collection.insert key: 'my_lock', owner: 'tobie', expires_at: 1.minute.from_now
+ my_collection.insert key: 'my_lock', owner: 'tobie', expires_at: 1.minute.from_now
expect(lock.available?).to be_false
end
end