spec/client_spec.rb in redis_failover-0.2.0 vs spec/client_spec.rb in redis_failover-0.3.0

- old
+ new

@@ -9,11 +9,11 @@ def current_slaves @slaves end - def fetch_redis_servers + def fetch_nodes { :master => 'localhost:6379', :slaves => ['localhost:1111'], :unreachable => [] } @@ -29,10 +29,22 @@ end it 'properly parses slaves' do client.current_slaves.first.to_s.should == 'localhost:1111' end + + it 'does not rebuild clients if hosts have not changed' do + class << client + attr_reader :built_new_client + def new_clients_for(*) + @built_new_client = true + end + end + + 5.times { client.send(:build_clients) } + client.built_new_client.should_not be_true + end end describe '#dispatch' do it 'routes write operations to master' do client.current_master.should_receive(:del) @@ -49,9 +61,18 @@ class << client attr_reader :reconnected def build_clients @reconnected = true super + end + + def fetch_nodes + @calls ||= 0 + { + :master => "localhost:222#{@calls += 1}", + :slaves => ['localhost:1111'], + :unreachable => [] + } end end client.current_master.make_unreachable! client.del('foo')