From: 7stud -- Date: 2007-10-14T00:19:24+09:00 Subject: Re: strategy for unit testing user input? Kurt Walker wrote: > 7stud -- wrote: >> Hi, >> >> I have a program that prompts the user on the command line to enter some >> data. What are some ways to unit test the method that obtains the >> input? > > I'm not sure if you found an answer to this. I came across your post > when I was looking for an answer to the same thing. The best way I > found is to use flexmock (or other mock tool). > > flexmock($stdout){|mock| mock.should_receive("puts").with("enter > something")} > flexmock($stdin){|mock| mock.should_receive("gets").and_return("junk")} > Thanks. -- Posted via http://www.ruby-forum.com/.