Skip to content

Commit

Permalink
Always incldue redis-db in client description
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan W. Zaleski committed Mar 2, 2013
1 parent 0800964 commit 08bd235
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/redis_failover/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 08bd235

Please sign in to comment.