spec/client_spec.rb in redis_failover-0.4.0 vs spec/client_spec.rb in redis_failover-0.5.0
- old
+ new
@@ -16,35 +16,25 @@
:master => 'localhost:6379',
:slaves => ['localhost:1111'],
:unavailable => []
}
end
+
+ def setup_zookeeper_client; end
end
describe Client do
- let(:client) { ClientStub.new(:host => 'localhost', :port => 3000) }
+ let(:client) { ClientStub.new(:zkservers => 'localhost:9281') }
describe '#build_clients' do
it 'properly parses master' do
client.current_master.to_s.should == 'localhost:6379'
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)
@@ -55,11 +45,11 @@
client.current_slaves.first.change_role_to('slave')
client.current_slaves.first.should_receive(:get)
client.get('foo')
end
- it 'reconnects with redis failover server when node is unavailable' do
+ it 'reconnects when node is unavailable' do
class << client
attr_reader :reconnected
def build_clients
@reconnected = true
super
@@ -76,15 +66,9 @@
end
client.current_master.make_unavailable!
client.del('foo')
client.reconnected.should be_true
- end
-
- it 'fails hard when the failover server is unavailable' do
- expect do
- Client.new(:host => 'foo', :port => 123445)
- end.to raise_error(FailoverServerUnavailableError)
end
it 'properly detects when a node has changed roles' do
client.current_master.change_role_to('slave')
expect { client.send(:master) }.to raise_error(InvalidNodeRoleError)