Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always include redis-db in client description #53

Merged
merged 1 commit into from Mar 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/redis_failover/client.rb
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
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