@@ -29,8 +29,7 @@ def test_list_of_hosts_with_first_host_successful
2929 [ "fail.SocketError" , 636 ] ,
3030 ]
3131
32- connection = Net ::LDAP ::Connection . new ( :hosts => hosts )
33- connection . socket_class = FakeTCPSocket
32+ connection = Net ::LDAP ::Connection . new ( :hosts => hosts , :socket_class => FakeTCPSocket )
3433 connection . socket
3534 end
3635
@@ -41,8 +40,7 @@ def test_list_of_hosts_with_first_host_failure
4140 [ "fail.SocketError" , 636 ] ,
4241 ]
4342
44- connection = Net ::LDAP ::Connection . new ( :hosts => hosts )
45- connection . socket_class = FakeTCPSocket
43+ connection = Net ::LDAP ::Connection . new ( :hosts => hosts , :socket_class => FakeTCPSocket )
4644 connection . socket
4745 end
4846
@@ -53,8 +51,7 @@ def test_list_of_hosts_with_all_hosts_failure
5351 [ "fail.SocketError" , 636 ] ,
5452 ]
5553
56- connection = Net ::LDAP ::Connection . new ( :hosts => hosts )
57- connection . socket_class = FakeTCPSocket
54+ connection = Net ::LDAP ::Connection . new ( :hosts => hosts , :socket_class => FakeTCPSocket )
5855 assert_raise Net ::LDAP ::ConnectionError do
5956 connection . socket
6057 end
@@ -75,24 +72,21 @@ def test_result_for_connection_failed_is_set
7572 end
7673
7774 def test_unresponsive_host
78- connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ETIMEDOUT" , :port => 636 )
79- connection . socket_class = FakeTCPSocket
75+ connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ETIMEDOUT" , :port => 636 , :socket_class => FakeTCPSocket )
8076 assert_raise Net ::LDAP ::Error do
8177 connection . socket
8278 end
8379 end
8480
8581 def test_blocked_port
86- connection = Net ::LDAP ::Connection . new ( :host => "fail.SocketError" , :port => 636 )
87- connection . socket_class = FakeTCPSocket
82+ connection = Net ::LDAP ::Connection . new ( :host => "fail.SocketError" , :port => 636 , :socket_class => FakeTCPSocket )
8883 assert_raise Net ::LDAP ::Error do
8984 connection . socket
9085 end
9186 end
9287
9388 def test_connection_refused
94- connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ECONNREFUSED" , :port => 636 )
95- connection . socket_class = FakeTCPSocket
89+ connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ECONNREFUSED" , :port => 636 , :socket_class => FakeTCPSocket )
9690 stderr = capture_stderr do
9791 assert_raise Net ::LDAP ::ConnectionRefusedError do
9892 connection . socket
@@ -102,7 +96,7 @@ def test_connection_refused
10296 end
10397
10498 def test_connection_timeout
105- connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ETIMEDOUT" , :port => 636 )
99+ connection = Net ::LDAP ::Connection . new ( :host => "fail.Errno::ETIMEDOUT" , :port => 636 , :socket_class => FakeTCPSocket )
106100 stderr = capture_stderr do
107101 assert_raise Net ::LDAP ::Error do
108102 connection . socket
@@ -111,8 +105,8 @@ def test_connection_timeout
111105 end
112106
113107 def test_raises_unknown_exceptions
114- connection = Net ::LDAP ::Connection . new ( :host => "fail.StandardError" , :port => 636 )
115- assert_raise Net :: LDAP :: Error do
108+ connection = Net ::LDAP ::Connection . new ( :host => "fail.StandardError" , :port => 636 , :socket_class => FakeTCPSocket )
109+ assert_raise StandardError do
116110 connection . socket
117111 end
118112 end
0 commit comments