Sha256: 6bcec589da352fd1e5eb27d8380aa66f45d154d48097b7650176c7674f51f7d5

Contents?: true

Size: 926 Bytes

Versions: 1

Compression:

Stored size: 926 Bytes

Contents

require 'spec_helper'

describe Aggro do
  describe '.initialize_hash_ring' do
    context 'when called without args' do
      it 'should initialize the hash ring from env variable' do
        hash_ring = Aggro.initialize_hash_ring
        expect(hash_ring.nodes).to include '10.0.0.1'
        expect(hash_ring.nodes).to include '10.0.0.2'
      end
    end

    context 'when called with an array' do
      it 'should initialize the hash ring from given array' do
        hash_ring = Aggro.initialize_hash_ring ['10.0.0.50']
        expect(hash_ring.nodes).to_not include '10.0.0.1'
        expect(hash_ring.nodes).to include '10.0.0.50'
      end
    end
  end

  describe '.hash_ring' do
    it 'should return a hash ring' do
      expect(Aggro.hash_ring).to be_a ConsistentHashing::Ring
    end

    it 'should return the same hash ring every time' do
      expect(Aggro.hash_ring).to eq Aggro.hash_ring
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.1 spec/lib/aggro_spec.rb