Creating a new socket is #new, not #connect

This commit is contained in:
Nick Thomas
2011-11-13 18:43:43 +00:00
parent 51175ddf56
commit 875820f011
2 changed files with 4 additions and 4 deletions

View File

@@ -11,14 +11,14 @@ require 'qmp_client/messages'
module QMPClient
def self.connect_unix(filename, &blk)
sock = UNIXSocket.connect(filename)
sock = UNIXSocket.new(filename)
connect_socket(sock, &blk)
ensure
sock.close if sock && !sock.closed?
end
def self.connect_tcp(host, port, local_host=nil, local_port=nil, &blk)
sock = TCPSocket.connect(host, port, local_host, local_port)
sock = TCPSocket.new(host, port, local_host, local_port)
connect_socket(sock, &blk)
ensure
sock.close if sock && !sock.closed?

View File

@@ -30,7 +30,7 @@ module TestQMPClient
cargs = ["127.0.0.1", 4440, "127.0.0.1", 40000]
mock_sock = mock("(tcp-socket)")
mock_sock.stubs(:closed? => false, :close => true)
TCPSocket.expects(:connect).with(*cargs).once.returns(mock_sock)
TCPSocket.expects(:new).with(*cargs).once.returns(mock_sock)
expects_socket_run(mock_sock)
runs_api_block = false
@@ -44,7 +44,7 @@ module TestQMPClient
def test_connect_unix
mock_sock = mock("(unix-socket)")
mock_sock.stubs(:closed? => false, :close => true)
UNIXSocket.expects(:connect).with("/tmp/test.sock").once.returns(mock_sock)
UNIXSocket.expects(:new).with("/tmp/test.sock").once.returns(mock_sock)
expects_socket_run(mock_sock)