On Thu, Jun 05, 2003 at 02:58:23PM +0900, Hal E. Fulton wrote:
> How would you test this? For my first pass, I 
> didn't have to make any changes to my X10 class;
> I just substituted a fake SerialPort class.
> 
> I want to use StringIO, but it's not obvious to me
> how to proceed.

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?

You could create it in the 'setup' part of Test::Unit.

Just a thought,

Brian.