Sha256: f264252aa2ca5f8c3fa2f6716739984f51ae6ad2a24f99472a4bc5472cc1b3d8

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

require 'spec_helper'

describe Mongo::Lock do

  configure_for_mongo

  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

1 entries across 1 versions & 1 rubygems

Version Path
mongo-lock-1.2.0 spec/initialise_spec.rb