Sha256: 978237c490fcc3aec294d40c9e73b98025f7847d46838101e86cb0b808b0c51b

Contents?: true

Size: 553 Bytes

Versions: 1

Compression:

Stored size: 553 Bytes

Contents

require 'spec_helper'

describe AggregateRef do
  subject(:ref) { AggregateRef.new(id) }

  let(:id) { SecureRandom.uuid }
  let(:fake_ring) { double(node_for: '10.0.0.70') }

  before do
    allow(Aggro).to receive(:hash_ring).and_return fake_ring
  end

  describe '#server' do
    it 'should return the server on which the aggregate lives' do
      expect(ref.server).to eq '10.0.0.70'
    end

    it 'should memorize the lookup to reduce hashing' do
      expect(fake_ring).to receive(:node_for).once
      5.times { ref.server }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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