Skip to content

Commit 38ca0f2

Browse files
marcoowdjanowski
authored andcommitted
fixed and added test for Redis::Distributed#inspect
1 parent ead389d commit 38ca0f2

5 files changed

+15
-8
lines changed

lib/redis/distributed.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def inspect
659659
node_info = nodes.map do |node|
660660
"#{node.id} (Redis v#{node.info['redis_version']})"
661661
end
662-
"<Redis client v#{Redis::VERSION} connected to #{node_info.join(', ')}>"
662+
"#<Redis client v#{Redis::VERSION} connected to #{node_info.join(', ')}>"
663663
end
664664

665665
protected

test/distributed_internals_test.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
end
1414

1515
$TEST_PIPELINING = false
16-
$TEST_INSPECT = false
1716

1817
load File.expand_path("./lint/internals.rb", File.dirname(__FILE__))
18+
19+
test "provides a meaningful inspect" do |r, _|
20+
nodes = ["redis://localhost:6379/15", *NODES]
21+
@r = Redis::Distributed.new nodes
22+
23+
node_info = nodes.map do |node|
24+
"#{node} (Redis v#{@r.info.first["redis_version"]})"
25+
end
26+
assert "#<Redis client v#{Redis::VERSION} connected to #{node_info.join(', ')}>" == @r.inspect
27+
end

test/distributed_test.rb

-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@
5757
r.not_yet_implemented_command
5858
end
5959
end
60-

test/internals_test.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
end
1313

1414
$TEST_PIPELINING = true
15-
$TEST_INSPECT = true
1615

1716
load File.expand_path("./lint/internals.rb", File.dirname(__FILE__))
1817

18+
test "provides a meaningful inspect" do |r, _|
19+
assert "#<Redis client v#{Redis::VERSION} connected to redis://127.0.0.1:6379/15 (Redis v#{r.info["redis_version"]})>" == r.inspect
20+
end
21+
1922
test "Redis.current" do
2023
Redis.current.set("foo", "bar")
2124

test/lint/internals.rb

-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
end
2828
end
2929

30-
test "provides a meaningful inspect" do |r, _|
31-
assert "#<Redis client v#{Redis::VERSION} connected to redis://127.0.0.1:6379/15 (Redis v#{r.info["redis_version"]})>" == r.inspect
32-
end if $TEST_INSPECT
33-
3430
test "raises on protocol errors" do
3531
redis_mock(:ping => lambda { |*_| "foo" }) do
3632
assert_raise(Redis::ProtocolError) do

0 commit comments

Comments
 (0)