Skip to content

Instantly share code, notes, and snippets.

@vangberg
Created March 3, 2009 13:42
Show Gist options
  • Select an option

  • Save vangberg/73320 to your computer and use it in GitHub Desktop.

Select an option

Save vangberg/73320 to your computer and use it in GitHub Desktop.
class MockSocket
def self.pipe
socket1, socket2 = new, new
socket1.in, socket2.out = IO.pipe
socket2.in, socket1.out = IO.pipe
[socket1, socket2]
end
attr_accessor :in, :out
def gets() @in.gets end
def puts(m) @out.puts(m) end
def eof?() @in.eof? end
def empty?
begin
@in.read_nonblock(1)
false
rescue Errno::EAGAIN
true
end
end
end
@socket, @server = MockSocket.pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment