Sha256: c2a5a2581ceb49e21539d3f2bac57e97c5861e8782b05f380101d94e975529f1

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

require 'spec_helper'

describe Mongo::Lock do

  describe '#initialise' do

    let(:lock) { Mongo::Lock.new 'my_lock', owner: 'spence', timeout_in: 0.01, frequency: 0.01 }

    it "creates a new configuration object" do
      expect(lock.configuration).to be_a Mongo::Lock::Configuration
    end

    it "passes it the class configuration" do
      Mongo::Lock.configure limit: 3
      expect(lock.configuration.limit).to be 3
    end

    it "allows override of the class configuration" do
      Mongo::Lock.configure limit: 3
      lock = Mongo::Lock.new 'my_lock', limit: 4
      expect(lock.configuration.limit).to be 4
    end

    context "when the key is already acquired by this owner" do

      it "acquires that lock" do
        my_collection.insert key: 'my_lock', owner: 'spence', expires_at: 1.minute.from_now
        expect(lock.acquired?).to be_true
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo-lock-1.1.4 spec/initialise_spec.rb
mongo-lock-1.1.3 spec/initialise_spec.rb
mongo-lock-1.1.1 spec/initialise_spec.rb