Permalink
Browse files

Merge pull request #53 from jzaleski/always_include_db_in_client_desc…

…ription

Always incldue redis-db in client description
  • Loading branch information...
2 parents 0800964 + 08bd235 commit 91e3bed5fa6d227d4b0e76124a82c6f906c9e7b0 @ryanlecompte committed Mar 3, 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 91e3bed

Please sign in to comment.