Skip to content

Commit

Permalink
Provide a more meaningful inspect.
Browse files Browse the repository at this point in the history
  • Loading branch information
djanowski committed Jun 6, 2010
1 parent 90f28bf commit b870e44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/redis.rb
Expand Up @@ -519,6 +519,10 @@ def id
@client.id
end

def inspect
"#<Redis client v#{Redis::VERSION} connected to #{id} (Redis v#{info["redis_version"]})>"
end

def method_missing(command, *args)
@client.call(command, *args)
end
Expand Down
4 changes: 4 additions & 0 deletions test/redis_test.rb
Expand Up @@ -82,6 +82,10 @@ class RedisTest < Test::Unit::TestCase
@r.info
end
end

test "provides a meaningful inspect" do
assert_equal "#<Redis client v#{Redis::VERSION} connected to redis://127.0.0.1:6379/15 (Redis v#{@r.info["redis_version"]})>", @r.inspect
end
end

context "Connection handling" do
Expand Down

0 comments on commit b870e44

Please sign in to comment.