Sha256: 40a75efd47f1e5f454b85fa64bea7d6fe6e3ce2a2821263e0f5a65a0c817c619

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'
include FastCache

describe BasicRouter, '.new' do

  it 'should take a nodes list, bucket delegate, and hashing delegate' do
    router = BasicRouter.new([], ModulusBucket, CRC32)
    router.bucket_delegate.should be_kind_of(ModulusBucket)
    router.hash_delegate.should == CRC32
  end

  it 'should default to modulus and crc32 based delegates' do
    router = BasicRouter.new([])
    router.bucket_delegate.should be_kind_of(ModulusBucket)
    router.hash_delegate.should == CRC32
  end

end

describe BasicRouter, '#route' do

  before :each do
    @nodes = [:one, :two, :three, :four]
    @router = BasicRouter.new(@nodes)
  end

  it 'should route to the same buck if the string representation is the same' do
    @router.route(:key) {|n| @n1 = n}
    @router.route('key') {|n| @n2 = n}
    @n1.should == @n2
  end

  it 'should return a node' do
    @nodes.should include(@router.route('x') {|n| n})
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
binary42-fastcache-0.2 spec/routing/basic_router_spec.rb
binary42-fastcache-0.3 spec/routing/basic_router_spec.rb