From: "Hal E. Fulton" Date: 2003-06-06T01:49:27+09:00 Subject: Re: A unit testing problem... ----- Original Message ----- From: "Brian Candler" To: "ruby-talk ML" Sent: Thursday, June 05, 2003 6:54 AM Subject: Re: A unit testing problem... > Could you use a couple of IO.pipe objects instead, and run your mock object > as a separate thread? (or a separate process) > > ISTM that the mock object will want to receive characters down this pipe one > at a time, when it has enough to process a command then it will do it > and send the result back. Hence there has to be some buffering 'slack' > between the two, and it needs to be able to run asynchronously. > > Actually, for simplicity you could write your device simulator as a separate > program, which you run like this: > > f = IO.pipe("/path/to/my/simulator") > # now you can just read and write to f as if it were as serial port? Hmmm. This sounds neat. I've actually fallen out of the habit of using IO.pipe, since it quit working for awhile on Windows. (It may work now, I don't know.) But now I'm migrating to Linux, so why not? Yet I don't want to build too much intelligence into the simulator. I'd have to parameterize it somehow, in order to handle different scenarios. I will keep this in mind, but I'm thinking I will try Jim's approach. Thanks, Hal