Permalink
Browse files

Always incldue redis-db in client description

  • Loading branch information...
1 parent 0800964 commit 08bd235baec29ad93ad7ba7b231b5cd8fd9b226d Jonathan W. Zaleski committed Mar 2, 2013
Showing with 13 additions and 1 deletion.
  1. +1 −1 lib/redis_failover/client.rb
  2. +12 −0 spec/client_spec.rb
@@ -123,7 +123,7 @@ def respond_to_missing?(method, include_private)
# @return [String] a string representation of the client
def inspect
- "#<RedisFailover::Client (master: #{master_name}, slaves: #{slave_names})>"
+ "#<RedisFailover::Client (db: #{@db.to_i}, master: #{master_name}, slaves: #{slave_names})>"
end
alias_method :to_s, :inspect
View
@@ -54,6 +54,18 @@ def setup_zk
called.should be_true
end
+ describe '#inspect' do
+ it 'should always include db' do
+ opts = {:zkservers => 'localhost:1234'}
+ client = ClientStub.new(opts)
+ client.inspect.should match('<RedisFailover::Client \(db: 0,')
+ db = '5'
+ opts.merge!(:db => db)
+ client = ClientStub.new(opts)
+ client.inspect.should match("<RedisFailover::Client \\(db: #{db},")
+ end
+ end
+
context 'with :master_only false' do
it 'routes read operations to a slave' do
called = false

0 comments on commit 08bd235

Please sign in to comment.