Created
March 3, 2009 13:42
-
-
Save vangberg/73320 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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